2
Answers

Open Outlook from .Net Application

b b

b b

14y
3.4k
1
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)
0
Muhammad usman
NA 6 0 14y
The Earth is not a ccda place to be taken lightly. It is a place of complexity and must be put under a close and observed eye because it need to be understood in all oracle training aspects by means of life, nature, and spirit. The Native Americans are sure to constantly take pride ion all they set out to do in life. This is a positive way of thinking and can be put into contrast to the American view of all life forms. American take things for security+ granted and are ususally never satisfied. This can be assumed to be a problem for society and a way to overcome this could be bettered through the help of the Native Americans. The Native Americans have many beneficial outlooks on life that can only do americans good. By taking in this cissp exam information from the Native Americans Americans can only live out a life of increasing successs through the positive feedback that the earth gives them.
0
Hirendra Sisodiya
NA 8.8k 3m 14y

try this code:
 
Microsoft.Office.Interop.Outlook.
Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.
MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
Microsoft.Office.Interop.Outlook.
Recipient oRecip = (Microsoft.Office.Interop.Outlook.Recipient)oMsg.Recipients.Add("e-mail address");
oRecip.Resolve();
oMsg.Subject =
"";
oMsg.Body =
"";
String sSource = "C:\\cmd.txt";
String sDisplayName = "MyFirstAttachment";
oMsg.Attachments.Add(sSource, 1, 1, sDisplayName);
oMsg.Display(
true);
 
thanks
Please mark as answer if it helps