Last post Nov 02, 2015 11:11 AM by bbcompent1
Oct 13, 2015 07:59 AM|bbcompent1|LINK
Well, I have been struggling with this whole opening an HTML email body inside an outlook email form but it would appear the text comes up as raw un-encoded HTML. I'm looking for some way to instruct Outlook to render the body as HTML. Here is my HTML
email output section of the code:
protected void btnSubmit_Click(object sender, EventArgs e)
Outlook.Application oApp = new Outlook.Application();
Outlook._MailItem oMail = (Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMail.To = string.Empty;
oMail.Subject = "Security Evaluation: " + txtAppName.Text.ToString();
oMail.HTMLBody = "Hello, we have audited the application titled " + txtAppName.Text.ToString() + ". Please reply to us with your comments/fixes.<br /><br />" + Label1.Text.ToString() + "<br /><br /> Please let us know if you have any questions.<br /><br /><br /> Thank you.";
btnSubmit.Visible = false;
catch (Exception ex)
Response.Write("Uh oh, something went wrong. Error: " + ex.ToString());
This code works great if I am on my local machine but it does not open the form on the client if deployed to production. I had considered doing a copy/paste into the body of the email form and that would be super, IF c#.net could paste it automatically after
the outlook form opens.
Oct 13, 2015 09:14 AM|PatriceSc|LINK
it does not open the form on the client if deployed to production
It will never work. Keep in mind that this code runs on the web server so it appeared to be ok on your own machine as the server and the client are the same machine. It will never work in production as it runs on a real web server (so at best it would open
Outlook on the web server).
You could try:
https://msdn.microsoft.com/en-us/library/aa767737(v=vs.85).aspx (a "mailto" Href link)
Sending maybe a .eml file could also perhaps work (the user would choose "Open" and it would open with the default app for .eml files).
Oct 13, 2015 09:27 AM|bbcompent1|LINK
Hm, responsing an .eml file from the server? Now that could work. The user base would know to expect that since I would be training them. I'll look at the link you included to see what that has. If you have code the will response a streamed .eml file
to the client that opens in their mail client, that would be perfect.
Nov 02, 2015 11:11 AM|bbcompent1|LINK
Patrice, can you help me figure this out please? I have another thread related to creating an EML file which contains the contents of the formatted email. Can you take a look?