Take the 2-minute tour ×

Is it possible to send email with outlook despite my server doesnt install outlook 2010 and its within the intranet zone? Because everyone here communicate with outlook and had a unique outlook account. How can i send email from my application? I am pretty sure i cannt use the following code to solve my problem, someone please help me.


// Create the Outlook application.
Outlook.Application oApp = new Outlook.Application();
// Create a new mail item.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
// Set HTMLBody. 
//add the body of the email
oMsg.HTMLBody = body;
//Add an attachment.
//String sDisplayName = "MyAttachment";
///int iPosition = (int)oMsg.Body.Length + 1;
//int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
//now attached the file
//Outlook.Attachment oAttach = oMsg.Attachments.Add(@"C:\\fileName.jpg", iAttachType, iPosition, sDisplayName);

//Subject line
oMsg.Subject = subject;
// Add a recipient.
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
// Change the recipient in the next line if necessary.
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(address);
// Send.
// Clean up.
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
share|improve this question
Did any answer help you out? Please mark as answer. –  Rob Nov 13 '12 at 13:37

3 Answers 3

This improves another answer, because that sample code doesn´t work.

If this doesn't have to be outlook, try this:

using System.Net.Mail;
using System.Net;

private void SendMail( string targetMail, 
                       string shownTargetName, 
                       string[] attachmentNames) {
  var fromAddress = new MailAddress("support@e-volution-software.de", "MailSendingProgram");
  var toAddress = new MailAddress(targetMail, shownTargetName);
  const string fromPassword = "12345isAbadPassword";
  subject = "Your Subject";
  body = 
          Here you can put in any text that will appear in the body
          multilined and even in <html>
  var smtp = new SmtpClient {
    Host = "smtp.1und1.de",
    Port = 587,
    EnableSsl = true,
    DeliveryMethod = SmtpDeliveryMethod.Network,
    UseDefaultCredentials = false,
    Credentials = new NetworkCredential(fromAddress.Address, fromPassword)

  using (var message = new MailMessage(fromAddress, toAddress) {
                             Subject = subject,
                             Body = body }
        ) {
    foreach(string filePath in attachmentNames[]) {
      Attachment attachMail = new Attachment(filePath);

    try {
      MessageBox.Show("E-Mail sent!");
    } catch {
      MessageBox.Show("Sending failed, check your internet connection!");

In this example there is everything you need including File Attachments.

share|improve this answer

If you want to send email you didn't need outlook you need email adres, for example

MailMessage mail = new MailMessage();
mail.From = ""; // put the from address here
mail.To = ""; // put to address here
mail.Subject = ""; // put subject here
mail.Body = ""; // put body of email here
SmtpMail.SmtpServer = ""; // put smtp server you will use here
// and then send the mail

and read this Send email


But if you want to use OUTLOOK try this

using Outlook = Microsoft.Office.Interop.Outlook;

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

                    Outlook.MailItem email = (Outlook.MailItem)(oApp.CreateItem(Outlook.OlItemType.olMailItem));
                    email.Subject = "Subject";
                    email.Body = "Message";



Example of first code

System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.From = new System.Net.Mail.MailAddress("mymail@gmail.com");//who send
mm.To.Add(new System.Net.Mail.MailAddress("Yourmail@gmail.com"));//where send
mm.Subject = "Subj";
mm.Body = "text";
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("");
share|improve this answer
@HuatsinYeo read edit part, i hope it will help you –  Likurg May 3 '12 at 9:09
I have COM Exception..does it mean that any address will work in your code? –  Huatsin Yeo May 3 '12 at 9:31
@HuatsinYeo you try edit part or first? –  Likurg May 3 '12 at 9:48
both, but first gives me a connection error, says it could not connect to the server.. –  Huatsin Yeo May 3 '12 at 10:01
@HuatsinYeo You need to read this for use edit part c-sharpcorner.com/UploadFile/casperboekhoudt/… –  Likurg May 3 '12 at 10:06

in asp.net you can also send email through user's outlook using script manager:

//add this to your page body (or in master page body)
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"/>

//add this to your SendEmailButton_Click() event
string email = "mailto:recipient@domain.com?subject=my subject&body=my message.";
StringBuilder sb = new StringBuilder();
sb.Append("document.location.href='" + email + "';");
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sendemail", sb.ToString(), true);
share|improve this answer

Your Answer


