Tuesday, November 20, 2007

Configure Outlook for your application

Outlook.Application oApp = new Outlook.Application();

Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMsg.ExpiryTime = DateTime.Today;
//Add a recipient.
Outlook.Recipient oRecip = (Outlook.Recipient)oMsg.Recipients.Add("emailaddress");
oRecip.Resolve();

////Set the basic properties.
oMsg.Subject = "This is the subject of the test message for Using Outlook";
oMsg.Body = "Hi";

////Add an attachment.
//// TODO: change file path where appropriate
String sSource = "C:\\realtek.log";
String sDisplayName = "Just testing";
int iPosition = (int)oMsg.Body.Length + 1;
int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
Outlook.Attachment oAttach = oMsg.Attachments.Add(sSource, iAttachType, iPosition, sDisplayName);
oMsg.Display(oApp);

For the above code in C++/CLI just mail me.

Regards
Ajith

No comments: