A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

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



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 6th 10, 11:14 AM posted to microsoft.public.outlook.program_addins
hemaneelagiri via OfficeKB.com
external usenet poster
 
Posts: 22
Default 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

Ads
  #2  
Old January 6th 10, 03:54 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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


  #3  
Old January 7th 10, 06:02 AM posted to microsoft.public.outlook.program_addins
hemaneelagiri via OfficeKB.com
external usenet poster
 
Posts: 22
Default 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

  #4  
Old January 7th 10, 08:08 AM posted to microsoft.public.outlook.program_addins
hemaneelagiri via OfficeKB.com
external usenet poster
 
Posts: 22
Default 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

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Possibility to color-code mail folders in Outlook SaSo Outlook - Installation 0 December 4th 09 01:05 AM
A code that adds category to an outgoing mail message in outlook newED Outlook and VBA 7 August 3rd 09 07:50 PM
Possibility to color-code mail folders in Outlook glennn.php Outlook - Installation 5 February 15th 09 09:51 AM
how can I set a pass code to my outlook so only I can open mail MR.LEE[_2_] Outlook - General Queries 1 December 17th 08 04:14 AM
Outlook2003 failing to launch after first launch njmeatball Outlook - Installation 4 October 25th 06 10:29 PM


All times are GMT +1. The time now is 01:04 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-2025 Outlook Banter.
The comments are property of their posters.