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

  • Thread starter Thread starter hemaneelagiri
  • Start date Start date
Status
Not open for further replies.
H

hemaneelagiri

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


201001
 
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.

"hemaneelagiri " <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

> >
> 201001
>
 
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.OlItemType.

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
- 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


 
Thanks i got the solution

oMsg.Display(false);

hemaneelagiri wrote:
> 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.OlItemType.
> 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


 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Outlook launch email showing new unread email in reading pane Using Outlook 11
D Launch Outlook showing only selected messages. Using Outlook 1
D Outlook 2010 won't launch after installin Microsoft office 2010 service pack 1 Using Outlook 1
A Outlook 2010 VBA fails to launch Outlook VBA and Custom Forms 2
D Mail in Control Panel Won't Launch Exchange Server Administration 5
D How do I get a new mail icon into my quick launch bar? Using Outlook 3
F Launch Marketing Campaign Error BCM (Business Contact Manager) 7
T How to Cancel a queued addon installation on Outlook2003 Launch Outlook VBA and Custom Forms 1
M How to launch macro within a rule? Outlook VBA and Custom Forms 8
R Outlook ribbon menu default? Using Outlook 4
H Spam email in Gmail not visible in Outlook Using Outlook 3
J How to transfer Win 10 Outlook to new Windows 11 pc? Using Outlook 8
J Renegade spam URL line displayed in old local Outlook 365 email title Using Outlook 3
G Reduce whitespace in Outlook desktop Contact Cards display Using Outlook 3
C Outlook classic via 365 Using Outlook 2
Dr. Demento Analogous Outlook code to read info into an array (or collection or whatever) Outlook VBA and Custom Forms 7
S Repair Outlook Using Outlook 8
V Outlook Form ListBox is not editable Outlook VBA and Custom Forms 2
F Outlook's contacts Using Outlook 1
D Outlook 2003 stopped dead Using Outlook 2
G Cannot receive emails from gmail account in Outlook 365 Using Outlook 1
E "Cannot display the folder. MS Outlook cannot access the specified file location" Using Outlook 8
P Outlook 2016 Working Offline Using Outlook 2
Rupert Dragwater Cannot reestablish gmail (email address) account in Outlook 365 Using Outlook 11
O Outlook 365 synchronisieren Exchange Server Administration 1
kburrows Outlook Classic - JPG files are corrupted when opened or saved Using Outlook 3
F Sync Outlook Calendar Using Outlook 0
G Change default font size in sticky notes - Outlook Desktop 2021 Using Outlook 2
C VBA in "New Outlook?" Using Outlook 0
D New Outlook with Business Basic Plans Using Outlook 0
D Outlook 2021 not working with Outlook 2003 installed Using Outlook 5
D Outlook 2003 stopped working - get they dialog box asking for username & Password Using Outlook 2
T Outlook 2021 hangs in close on taskbar occasionally Using Outlook 1
M Duplicate removal feature in Outlook 2021 is faulty Using Outlook 2
D.Moore Outlook COM addins source folder Using Outlook 12
P Removing Outlook 365 Account from Send/Receive Using Outlook 3
kburrows Outlook Automatically Merging Contacts Using Outlook 2
A Outlook 2016 Outlook 2016 vs. New Outlook Using Outlook 4
D Outlook Desktop App Email Software Using Outlook 0
efire9207 VBA Outlook Contacts Outlook VBA and Custom Forms 6
M Outlook not logging in to server Using Outlook 0
J Outlook macro to run before email is being send Outlook VBA and Custom Forms 3
R Outlook 2021 change view Using Outlook 2
K Outlook font corrupted in some point sizes, resets on close/open Using Outlook 2
J Is the Windows Outlook Tasks module really going to be gone? Using Outlook 6
F Outlook 2010 and Hotmail Using Outlook 1
A Outlook 2021 needs 'enter' for people search Using Outlook 2
HarvMan Outlook 365 Inbox Font Using Outlook 8
Retired Geek Outlook on MAC delete duplicate Sent emails Using Outlook 0
S New Outlook - IMAP ISSUES and support for addins? Using Outlook 1

Similar threads

Back
Top