How to choose acount in Outlook 2007 in c#

V

Vlasta

Can anybody help me how to choose acount in Outlook 2007 in c#? I have C#
application and I need to send from that application email, but not with
current acount, but with acount I choose. I try it with
mailItem.sendUsingAcount , but with no result.
My code looks like this:

Outlook.Application outlook = new Outlook.Application();
Outlook.MailItem mailItem =
(Outlook.MailItem)outlook.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Subject = "somethink";
mailItem.To = "email adres";
mailItem.Body = "Text in body";
mailItem.Importance = Outlook.OlImportance.olImportanceLow;
mailItem.Display(false);
mailItem.Send();

Thanks for answer Vlasta
 
K

Ken Slovak - [MVP - Outlook]

SendUsingAccount is exactly what you want to use. Have you looked at the
code sample for using it in the Object Browser Help for SendUsingAccount? It
does work.
 
V

Vlasta

I tried to find somethink, but unfortunately I wasn't succsessful. Can you
give me some link with code sample? Please.
Thanks Vlasta
 
Joined
Oct 3, 2009
Messages
1
Reaction score
0
This is the result:

Type objectType = Type.GetTypeFromProgID("Outlook.Application");
object outlookactivo = Activator.CreateInstance(objectType);
if (outlookactivo != null)
{
_outLook = (OutLook.Application)outlookactivo;
_outLook.Session.Application.NewMailEx += _outLook_NewMailEx;
}
private OutLook._Application _outLook = new OutLook.Application();
OutLook.MailItem msg = (OutLook.MailItem)this._outLook.CreateItem(OlItemType.olMailItem);
//text of mensaje and more data...
.....
msg.Send()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top