A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Using SenderEmailAddress



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3  
Old June 18th 07, 09:16 PM posted to microsoft.public.outlook.program_vba
BrianL
external usenet poster
 
Posts: 13
Default Using SenderEmailAddress

After reading the two replies from you and Eric, I have decided I'll take a
different route to get the address from the email (I'll go with the one
open). Does "myMailItem" select the email highlighted or opened?

Also, I have changed the code Eric gave me to better fit what I'm atempting
to do. If you see something wrong with what I changed, let me know:

Private Sub CommandButton1_Click()
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
Set myItem = Application.CreateItem(2)
If Application.ActiveExplorer.Selection.Count = 1 Then
If Application.ActiveExplorer.Selection(1).Class = olMail Then
Set myMailItem = Application.ActiveExplorer.Selection(1)
myItem.Email1Address = myMailItem.SenderEmailAddress
End If
End If
Unload Me
myItem.Display
End Sub

If I am correct, this code will set the Email of the selected message as
Email1address of myItem. Then it will close the form that I had open and open
the new contact form with the Email feild set as the Sender's email address.

Is this even close to doing what I thought? The only problem is that I do
not know of a way to have outlook automatically select messages when they are
recieved. Maybe if I flag them all as a color, and then tell my script to
open messages of a certain flag color? Oh, and I am interested in the
messages that are newly recieved, and have not yet been read.

If the messages are sorted by date, then could I use "myMailItem =
Items(1)" to select the newest message? Wow, this was a lengthy response,
sorry.

~Brian

"Sue Mosher [MVP-Outlook]" wrote:

"the first SenderEmailAddress in my inbox" doesn't have any precise definition when it comes to programming Outlook. Returning the currently open or currently selected items is no problem, nor is working with all the items in a folder. But if "first" relates to what the user sees, that's not so easy (if it's possible at all) to return that specific item. Maybe you can clarify which item you're interested in.

Note that you can name your variables anything you want. If myItem is already taken, then use myItem2 or myMail or mySandwich. (Sorry, just had lunch.)


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
senderemailaddress marco Outlook and VBA 1 June 7th 07 01:20 PM
SenderEmailAddress in VB.NET on Outlook 2003 [email protected] Add-ins for Outlook 1 April 10th 07 04:27 PM
How to change read only SenderName and SenderEmailAddress [email protected] Outlook - General Queries 3 April 19th 06 08:22 PM


All times are GMT +1. The time now is 08:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.