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

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
 
K

Ken Slovak - [MVP - Outlook]

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

hemaneelagiri

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


 
H

hemaneelagiri

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
S Adding a recipient's column to Sent folder in Outlook 2010 Outlook VBA and Custom Forms 1
J Outlook search bar in Office 2021 Professional Using Outlook 0
J PSA: How to create custom keyboard shortcut for "Paste Unformatted Text" in Outlook on Windows Outlook VBA and Custom Forms 1
C How to fix outlook continuing to prompt fo an Exchange password Using Outlook 0
C Outlook doesn't feel reliable, anymore Using Outlook 5
J Outlook 2016 Trying to get Outlook 2016 to work with Office 365 Using Outlook 0
C Outlook 365 Copy/Save Emails in Folder Outside Outlook to Show Date Sender Recipient Subject in Header Using Outlook 0
U Outlook not responding when trying to print Emails Using Outlook 3
O How to sync (one way) contacts between two Outlook (exchange) accounts? Using Outlook 0
S Sync Outlook (2021) tasks with Microsoft To Do Using Outlook 1
L Duplicate calendar entries in Outlook 365 Using Outlook 4
V Outlook 2021 Can anyone explain why my Outlook views keep changing?! Using Outlook 2
AlphonseG Outlook 365 Outlook Crashes on setting SaveSentMessageFolder Outlook VBA and Custom Forms 5
S Outlook 2021 How to customize colors Outlook 2021 & Office 2021 on PC Using Outlook 2
D Outlook 2007 Recovering E-Mails Using Outlook 0
G Stop Outlook 365 adding meetings to calendar Using Outlook 2
HarvMan Using Emojis in Outlook 365 Using Outlook 3
T Outlook 2019 Not Using Auto Compete After Deletion of 365 Using Outlook 1
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
Albert McCann Outlook 2021 Outlook Display of HTML Email from two senders is glitchy Using Outlook 0
richardwing Outlook 365 VBA to access "Other Actions" menu for incoming emails in outlook Outlook VBA and Custom Forms 0
J Unable to delete folders in Outlook 2019 / Windows Using Outlook 1
K Outlook for Mac problems Using Outlook 0
D Outlook app 2021 & iCloud PST issues Using Outlook 2
M c# vsto Outlook.ApplicationEvents_11_NewMailEx Outlook VBA and Custom Forms 1
J Event/Meeting in Outlook Does Not Align with SharePoint Calendar Using Outlook 5
Christopher M Is it me, or is Outlook 365 BUGGY? Using Outlook 3
U Outlook on the iPhone cannot approve filtered Emails Using Outlook 0
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 21
K Outlook 365 After migrating to Outlook 365, some contacts display in emails with prefixes Using Outlook 1
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
Horsepower Cannot delete gmail in iPhone Outlook outbox Using Outlook 1
F Outlook 2019 Outlook 2019 Add and Sync to New computer Comcast server Using Outlook 2
M Understanding Outlook Identities Using Outlook 1
kburrows Outlook or Phone Combining Contacts? Using Outlook 0
P Outlook 2013 search no longer works Using Outlook 2
M Accessing ALL Outlook contact fields Outlook VBA and Custom Forms 3
C Outlook (desktop app for Microsoft365) restarts every time I save my VBA? Using Outlook 0
R MailTips and older Outlook versions Using Outlook 0
A iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled Using Outlook 10
C How to import Outlook calendar? Using Outlook 1

Similar threads

Top