Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   want to launch outlook with attachemnet for new mail with c# code (http://www.outlookbanter.com/add-ins-outlook/98671-want-launch-outlook-attachemnet-new.html)

hemaneelagiri via OfficeKB.com January 6th 10 11:14 AM

want to launch outlook with attachemnet for new mail with c# code
 
hi
i want to lanuch outlook(default mail client) with an attachment
i am able to lanuch outlook with all except attachment
like bellow
string strAttach = "C:\\test.txt";
string mailto = string.Format("mailto:{0}?Subject={1}&Body={2}
&Attach={3}", "", "Test Mail", "Hema", strAttach);
//System.Diagnostics.Process.Start(mailto);

Process myProcess = new Process();
myProcess.StartInfo.FileName = mailto.ToString();
myProcess.StartInfo.UseShellExecute = true;
myProcess.StartInfo.RedirectStandardOutput = false;
myProcess.Start();
myProcess.Dispose();

but attachment is not coming

pelase help me

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/201001/1


Ken Slovak - [MVP - Outlook] January 6th 10 03:54 PM

want to launch outlook with attachemnet for new mail with c# code
 
Some combinations of startup switches don't work together. You can test that
in the UI by starting Outlook using those switches.

In any case you are better off starting an Outlook session and using the
CreateItem() method to create the email and then you can use the object
model to set subject, attachments, recipients, etc.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"hemaneelagiri via OfficeKB.com" u54138@uwe wrote in message
news:a1b334b725694@uwe...
hi
i want to lanuch outlook(default mail client) with an attachment
i am able to lanuch outlook with all except attachment
like bellow
string strAttach = "C:\\test.txt";
string mailto = string.Format("mailto:{0}?Subject={1}&Body={2}
&Attach={3}", "", "Test Mail", "Hema", strAttach);
//System.Diagnostics.Process.Start(mailto);

Process myProcess = new Process();
myProcess.StartInfo.FileName = mailto.ToString();
myProcess.StartInfo.UseShellExecute = true;
myProcess.StartInfo.RedirectStandardOutput = false;
myProcess.Start();
myProcess.Dispose();

but attachment is not coming

pelase help me

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/201001/1



hemaneelagiri via OfficeKB.com January 7th 10 06:02 AM

want to launch outlook with attachemnet for new mail with c# code
 
Thanks for your response

you mean to say Crete item. i am able to create item.. but how can we launch
that created mail

please see below code

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

Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

oNS.Logon(Missing.Value, Missing.Value, false, true);

Outlook._MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemTy pe.
olMailItem);

oMsg.Subject = strSubject;

oMsg.Body = strMessage;

fi = new System.IO.FileInfo(arrAttachPaths[i]);
iPosition = (int)oMsg.Body.Length + 1;
oMsg.Attachments.Add(fi.FullName, iAttachType, iPosition, fi.Name);

oMsg.To = strToIds; // use rshoukldenetr the To Id

// send mail.. but here new mail should launch and user will enetr that to
email id

oMsg.Send();

oNS.Logoff();

oMsg = null;
oNS = null;
oApp = null;

please help me



Ken Slovak - [MVP - Outlook] wrote:
Some combinations of startup switches don't work together. You can test that
in the UI by starting Outlook using those switches.

In any case you are better off starting an Outlook session and using the
CreateItem() method to create the email and then you can use the object
model to set subject, attachments, recipients, etc.

hi
i want to lanuch outlook(default mail client) with an attachment

[quoted text clipped - 15 lines]

pelase help me


--
Message posted via http://www.officekb.com


hemaneelagiri via OfficeKB.com January 7th 10 08:08 AM

want to launch outlook with attachemnet for new mail with c# code
 
Thanks i got the solution

oMsg.Display(false);



hemaneelagiri wrote:[i]
Thanks for your response

you mean to say Crete item. i am able to create item.. but how can we launch
that created mail

please see below code

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

Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

oNS.Logon(Missing.Value, Missing.Value, false, true);

Outlook._MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemTy pe.
olMailItem);

oMsg.Subject = strSubject;

oMsg.Body = strMessage;

fi = new System.IO.FileInfo(arrAttachPaths);
iPosition = (int)oMsg.Body.Length + 1;
oMsg.Attachments.Add(fi.FullName, iAttachType, iPosition, fi.Name);

oMsg.To = strToIds; // use rshoukldenetr the To Id

// send mail.. but here new mail should launch and user will enetr that to
email id

oMsg.Send();

oNS.Logoff();

oMsg = null;
oNS = null;
oApp = null;

please help me

Some combinations of startup switches don't work together. You can test that
in the UI by starting Outlook using those switches.

[quoted text clipped - 8 lines]

pelase help me


--
Message posted via http://www.officekb.com



All times are GMT +1. The time now is 10:28 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com