Send mail using default webclient in ASP.NET using MAPI in C# web application
Asked Answered
C

2

0

I am using MAPI for opening default web mail client in my C# web application. Now it is opening as dialog box first then outlook window. I want to open direct default mail client window using MAPI.

But when I am deploying on IIS then MAPI is not calling Mail Dialog box.

Is there simple way of calling web mail client using MAPI with attachment?

Crissycrist answered 2/9, 2012 at 9:44 Comment(0)
B
1

Don't use the MAPI. Use System.Net.Mail: http://www.systemnetmail.com/faq/3.4.1.aspx

static void AttachmentFromFile()
{
    //create the mail message
    MailMessage mail = new MailMessage();

    //set the addresses
    mail.From = new MailAddress("[email protected]");
    mail.To.Add("[email protected]");

    //set the content
    mail.Subject = "This is an email";
    mail.Body = "this content is in the body";

    //add an attachment from the filesystem
    mail.Attachments.Add(new Attachment("c:\\temp\\example.txt"));

    //to add additional attachments, simply call .Add(...) again
    mail.Attachments.Add(new Attachment("c:\\temp\\example2.txt"));
    mail.Attachments.Add(new Attachment("c:\\temp\\example3.txt"));

    //send the message
    SmtpClient smtp = new SmtpClient("127.0.0.1");
    smtp.Send(mail);

}
Baldachin answered 2/9, 2012 at 11:15 Comment(0)
A
0

Do you want to do that on the client of the server side? I doubt you will want any window to be displayed on the server when running in a service (IIS) where noone will dismiss these windows. If you want to run on the client side, mailto: url is pretty much your only choice.

Appreciation answered 2/9, 2012 at 18:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.