Question

I have a ASP.NET MVC 4 project with EF. I' m using System.Net.Mail to send emails programmatically.

MailMessage msg = new MailMessage();
msg.From = new MailAddress("JohnDoe@gmail.com", "John Doe");
msg.To.Add(new MailAddress("janedoe@gmail.com"));
msg.Subject = "Hi.";
msg.Body= "Aleluia";
var smtp = new SmtpClient("mail.johndoe.com", 999);
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential("JohnDoe@gmail.com", "johnspass");
smtpclient.Send(msg);

Q : How can I save a copy of this email in John Doe's Sent Items ? If I have Outlook can I use this ?

Q2 : How can I elaborate this email's body(to add a image in the left top corner, to add a bolded text) ?

Was it helpful?

Solution

I'm not sure if you can achieve this from a website, unless you have a way to manipulate a backend mail server and have access to manipulate users mailboxes.

The way outlook does this is by pushing any new sent email to the Sent Items folder and then it syncronizes the content with Exchange Server.

I also think Exchange server provides the API to achieve this behavior but your website would have to run under Windows Authentication to access and manipulate each user mailbox. I dont think is a good idea to give access to individual mailboxes to a global account (in this case the website pool identity account). You also might want to look into Exchange Web Services (2007 or greater).

This has been my experience with Exchange Server, I might be unaware of another allowed behavior and dont know anything about other mail servers in terms of APIs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top