In my application, I have a requirement where if a user clicks on invoice number the generated invoice statesment is attached to a composed email in outlook. Using code below i am able to send automated emails but i need to just compose and open the outlook window for user to review and edit the contents. Do not send. Kindly help.
public void pdfStatement(string InvoiceNumber)
{
InvoiceNumber = InvoiceNumber.Trim();
string mailServer = "server";
string fileName = InvoiceNumber;
string filePath = Server.MapPath("~/Content/reports/");
string messageBody = "Its an automated test email, please ignore if you receive this.";
CreateMessageWithAttachment(mailServer, filePath, fileName, messageBody);
}
public void CreateMessageWithAttachment(string mailServer, string filePath, string fileName, string messageBody)
{
MailMessage message = new MailMessage (
"user@domain.com",
"user@domain.com",
"TestEmail",
messageBody);
filePath = filePath + fileName + ".pdf";
// Create the file attachment for this e-mail message.
Attachment attach = new Attachment(filePath);
attach.Name = fileName + ".pdf";
// Add the file attachment to this e-mail message.
message.Attachments.Add(attach);
//Send the message.
SmtpClient client = new SmtpClient(mailServer);
var AuthenticationDetails = new NetworkCredential("user", "password");
client.Credentials = AuthenticationDetails;
client.Send(message);
}