.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Email >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Send mail with Outlook

Posted By:Athira Sreejith       Posted Date: February 22, 2009    Points: 10    Category: Email    URL: http://www.dotnetspark.com  
 

Send mail using your outlook pragmatically. Below is the C# code sample.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Diagnostics;

using System.IO;

using Microsoft.Reporting.WinForms;

using Outlook;

private void btnOutlook_Click(object sender, EventArgs e)

{

int Position = 1;

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

Outlook.MailItem Msg = (Outlook.MailItem)Outlookapp.CreateItem(Outlook.OlItemType.olMailItem);

Msg.Subject = "Testing Message";

Msg.Body = "Sample Text ";

if(Msg.Body != "")

Position = (int)Msg.Body.Length + 1;

Msg.To = "madhu.babu@sourceedge.com";

Msg.SentOnBehalfOfName = "ashok@sourceedge.com";

int AttachType = (int)Outlook.OlAttachmentType.olByValue;

Msg.Attachments.Add(@"C://tmp.xls", AttachType, Position, "Testing");

Msg.Send();

}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend