C# .NET - open outlook from C# - Asked By Anandh Ramanujam on 15-Feb-11 10:04 AM

Hi,

I need to open outlook with file attachment thro c# coding to send mail.

Can any body help me..

Thanks

Daivagna Nanavati replied to Anandh Ramanujam on 15-Feb-11 12:47 PM
Hi Anadah

You can use mailto tag to open outlook on hyperlink's click event like following

<a href="mailto:your_email_address">E-mail Me!</a>

and if you are using desktop application you can use following

Process.Start("mailto:bill@microsoft.com");

let me know

Thanks
Daivagna Nanavati replied to Anandh Ramanujam on 15-Feb-11 12:54 PM
Hi Anadah

You can use mailto tag to open outlook on hyperlink's click event like following

<a href="mailto:your_email_address">E-mail Me!</a>

and if you are using desktop application you can use following

Process.Start("mailto:bill@microsoft.com");

let me know

Thanks
Anoop S replied to Anandh Ramanujam on 16-Feb-11 12:21 AM

Here is the code  to open out look and set the to address and tittle and to do a attachment to that mail.


application.Visible = true;

book.SaveCopyAs(@”" + ConfigurationSettings.AppSettings["Reports"] + “Course Schedules for “ + lblProviderName.Text + “.xls”);

Outlook.Application outlookApp = new Outlook.Application();

Outlook.MailItem message = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);

message.Subject = “Course Schedules for “ + lblProviderName.Text + ” (“ + this.providerNumber + “) “;

message.Recipients.Add(“someone@email.com”);

message.Body = “”;

int attachmentLocation = 1;

message.Attachments.Add(“” + ConfigurationSettings.AppSettings["Atachments"] + “Course Schedules for “ + lblProviderName.Text + “.xls”, Outlook.OlAttachmentType.olByValue,

attachmentLocation, “Course Schedules for “ + lblProviderName.Text + “.xls”);

message.Display(false);