b b

b b

  • NA
  • 53
  • 0

Open Outlook from .Net Application

Sep 17 2010 1:16 AM
Hi All,

I want to open Outlook from my .net application with attachment.
I am using the following codes and its sending mails properly.
But its attaching the file in mail body area instead of attachment field of outlook. I want to attach the file in attachment textbox of outlook. Can anyone help me please.


Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
Outlook.Recipient oRecip = (Outlook.Recipient)oMsg.Recipients.Add("e-mail address");
oRecip.Resolve();

oMsg.Subject = "";
oMsg.Body = "";

String sSource = "C:\\test.txt";
String sDisplayName = "MyFirstAttachment";
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(true);


Regards,
B

Answers (2)