Click here to Skip to main content
15,892,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

Im trying to add the 'sender' field when sending an email using the Microsoft.Office.Interop.Outlook DLL, and having no luck.

I can create the message itself and add the recipient(s) easily with:
C#
// create the message
    Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

// add the recipient
    Outlook.Recipient oRecip = (Outlook.Recipient)oMsg.Recipients.Add("myemail@address.com");

// resolve recipient
    oRecip.Resolve();

// add the sender...?
oMsg.SendUsingAccount = ????;

But all the examples I've seen adding the sender either do it by finding the Account in the Contacts folder, or by looping through the entire Global Address List. I can do neither of these as the address(es) I will be sending from do not exist in the Contacts folder, and the GAL contains 125,000 entries, taking forever to loop through.

I can get the actual email address of the person I would like to do the sending from, but how do I then get the Account for this address and add it as the sender?

Many thanks,

Nick
Posted
Updated 29-May-13 6:11am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900