Outlook Interop Send Message from Account

Posted by Reiste on Stack Overflow See other posts from Stack Overflow or by Reiste
Published on 2010-05-17T07:58:37Z Indexed on 2010/05/24 7:41 UTC
Read the original article Hit count: 577

Filed under:
|
|

Okay, the specs have changed on this one somewhat. Maybe someone can help me with this new problem.

Manually, what the user is doing is opening an new message in Outlook (2007 now) which has the "From..." field exposed. They open this up, select a certain account from the Global Address List, and send the message on behalf of that account.

Is this possible to do?

I can get the AddressEntry from the Global address list like so:

        AddressList list = null;
        foreach (AddressList addressList in _outlookApp.Session.AddressLists)
        {
            if (addressList.Name.ToLower().Equals("global address list"))
            {
                list = addressList;
                break;
            }
        }

        if (list != null)
        {
            AddressEntry entry = null;
            foreach (AddressEntry addressEntry in list.AddressEntries)
            {
                if (addressEntry.Name.ToLower().Equals("outgoing mail account"))
                {
                    entry = addressEntry;
                    break;
                }
            }
         }

But I'm not sure I can make an Account type from the Address Entry. It seems to happen manually, when they select the address to send from. How do I mirror this in the Interop?

Thanks!

(My Original Question):

I developed a small C# program to send email using the Outlook 2007 interop. The client required that the mail not be send using the default account - they had a secondary account they needed used.

No problem - I used the Microsoft.Office.Interop.Outlook.Account class to access the availabled accounts, and choose the correct one.

Now, it turns out they need this to work in Outlook 2003. Of course, the Account class doesn't exist in the Outlook interop 11.0.

How can I achieve the same thing with Outlook 2003?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about interop

Related posts about outlook