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 » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Get email address from MailItem.To?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 1st 09, 09:41 AM posted to microsoft.public.outlook.program_addins
Mark B[_2_]
external usenet poster
 
Posts: 93
Default Get email address from MailItem.To?

VSTO OL2007 C#

When I am sending an email, how do I extract the email address component
from the TO field?

MailItem.Recipients field doesn't have any objects in the list before
Outlook sends an item. MailItem.To just has address book names and not email
addresses.

Ads
  #2  
Old September 1st 09, 03:04 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Get email address from MailItem.To?

Trap the item.Send() event and in that event save the item then read the
recipient properties you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark B" wrote in message
...
VSTO OL2007 C#

When I am sending an email, how do I extract the email address component
from the TO field?

MailItem.Recipients field doesn't have any objects in the list before
Outlook sends an item. MailItem.To just has address book names and not
email addresses.


  #3  
Old September 3rd 09, 04:59 AM posted to microsoft.public.outlook.program_addins
Mark B[_2_]
external usenet poster
 
Posts: 93
Default Get email address from MailItem.To?

Please excuse any newbie ignorance on this but I put a breakpoint after the
following code to see what mail.Recipients would expose for me in the
immediate window:

Outlook.MailItem mail1 = Item as Outlook.MailItem;
mail1.Save();

I could get mail1.Recipients.Count to return me 1. I thought
mail1.Recipients(1).emailaddress or similar would return me the raw email
address of the first recipient but I couldn't see that type of thing.

What code would I need to return me the email address?



"Ken Slovak - [MVP - Outlook]" wrote in message
...
Trap the item.Send() event and in that event save the item then read the
recipient properties you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark B" wrote in message
...
VSTO OL2007 C#

When I am sending an email, how do I extract the email address component
from the TO field?

MailItem.Recipients field doesn't have any objects in the list before
Outlook sends an item. MailItem.To just has address book names and not
email addresses.



  #4  
Old September 3rd 09, 07:33 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Get email address from MailItem.To?

mail1.Recipients.Item(1).Address
should work.
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Mark B" wrote in message
...
Please excuse any newbie ignorance on this but I put a breakpoint after
the following code to see what mail.Recipients would expose for me in the
immediate window:

Outlook.MailItem mail1 = Item as Outlook.MailItem;
mail1.Save();

I could get mail1.Recipients.Count to return me 1. I thought
mail1.Recipients(1).emailaddress or similar would return me the raw email
address of the first recipient but I couldn't see that type of thing.

What code would I need to return me the email address?



"Ken Slovak - [MVP - Outlook]" wrote in message
...
Trap the item.Send() event and in that event save the item then read the
recipient properties you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark B" wrote in message
...
VSTO OL2007 C#

When I am sending an email, how do I extract the email address component
from the TO field?

MailItem.Recipients field doesn't have any objects in the list before
Outlook sends an item. MailItem.To just has address book names and not
email addresses.





  #5  
Old September 3rd 09, 08:11 AM posted to microsoft.public.outlook.program_addins
Mark B[_2_]
external usenet poster
 
Posts: 93
Default Get email address from MailItem.To?


"Error 7 'Microsoft.Office.Interop.Outlook.Recipients' does not contain a
definition for 'Item' and no extension method 'Item' accepting a first
argument of type 'Microsoft.Office.Interop.Outlook.Recipients' could be
found (are you missing a using directive or an assembly reference?)"



"Dmitry Streblechenko" wrote in message
...
mail1.Recipients.Item(1).Address
should work.
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Mark B" wrote in message
...
Please excuse any newbie ignorance on this but I put a breakpoint after
the following code to see what mail.Recipients would expose for me in the
immediate window:

Outlook.MailItem mail1 = Item as Outlook.MailItem;
mail1.Save();

I could get mail1.Recipients.Count to return me 1. I thought
mail1.Recipients(1).emailaddress or similar would return me the raw email
address of the first recipient but I couldn't see that type of thing.

What code would I need to return me the email address?



"Ken Slovak - [MVP - Outlook]" wrote in message
...
Trap the item.Send() event and in that event save the item then read the
recipient properties you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark B" wrote in message
...
VSTO OL2007 C#

When I am sending an email, how do I extract the email address
component from the TO field?

MailItem.Recipients field doesn't have any objects in the list before
Outlook sends an item. MailItem.To just has address book names and not
email addresses.





  #6  
Old September 3rd 09, 03:07 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Get email address from MailItem.To?

In C# it would be mail1.Recipients[1].

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark B" wrote in message
...

"Error 7 'Microsoft.Office.Interop.Outlook.Recipients' does not contain a
definition for 'Item' and no extension method 'Item' accepting a first
argument of type 'Microsoft.Office.Interop.Outlook.Recipients' could be
found (are you missing a using directive or an assembly reference?)"


  #7  
Old September 3rd 09, 04:24 PM posted to microsoft.public.outlook.program_addins
Mark B[_2_]
external usenet poster
 
Posts: 93
Default Get email address from MailItem.To?

Thanks Ken, that works.

"Ken Slovak - [MVP - Outlook]" wrote in message
...
In C# it would be mail1.Recipients[1].

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark B" wrote in message
...

"Error 7 'Microsoft.Office.Interop.Outlook.Recipients' does not contain a
definition for 'Item' and no extension method 'Item' accepting a first
argument of type 'Microsoft.Office.Interop.Outlook.Recipients' could be
found (are you missing a using directive or an assembly reference?)"



 




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
Full email addres for mailItem.To pjerling Add-ins for Outlook 2 November 23rd 07 08:22 AM
Email as of type Outlook.MailItem css Outlook and VBA 3 August 11th 06 06:55 AM
How do I make a new email address supercede an old email address? dhbirt Outlook - Using Contacts 3 May 13th 06 05:38 AM
How can I create a MailItem that displays like a received MailItem ? Clive Outlook - Using Forms 0 February 27th 06 05:14 PM
Set which local email account can send mail to contacts in address book. (associating an email address with a contact) Scott Streit Outlook - General Queries 3 January 27th 06 03:57 PM


All times are GMT +1. The time now is 08:43 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.