Sending email with html body true having image using wcf service - c#

I am working on an application in MVC 4.0 dot net.When user first time visit the application a mail is sent to the user.For sending the mail i am using the WCF mail service implemented in our company.
I have created a .txt file having the HTML for mail format
this is the code I am using for sending the mail
public void SendWelcomeMail(string name, string email, string filePath)
{
try
{
string subject = ConfigurationManager.AppSettings["WelcomeMailSub"];
string supportMail = ConfigurationManager.AppSettings["supportMail"];
using (StreamReader reader = File.OpenText(filePath))
{
string text = reader.ReadToEnd();
text = string.Format(text, name);
Mail mails = new Mail { MailTo = "suresh.negi89#gmail.com", Msg = text, Subject = subject, IsBodyHtml = true };
MailSenderServiceClient oClient = new MailSenderServiceClient();
oClient.SendMail(mails);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
This is the file having the HTML format:
<html>
<body><
<div style="height:40px;width:675px;background:#000; text-align:center;color:red;">
<img src="~/Content/logo.png" alt="DTD" style="float:left">
<h1> {0} Congrates you are registered as a prime user!! </h1>
</div>
<p style="font-family: arial,sans-serif;">
Hi, Welcome to you
</p>
</body>
</html>
The image file logo.png is in Content folder.
When mail is sent no image is displayed.I want to know where I am doing mistake.

Where do you expect ~/Content/logo.png to point to on the recipient's machine?
99% of the time it will point nowhere, and the other 1% won't be the file you wanted anyway.
Three solutions:
Host your image on a public server and reference it with the full absolute URL (it's probably already there?). This is basically the de facto standard now.
<img src="http://www.example.com/logo.png" />
If this location changes, you can of course use a placeholder and resolve the URL at runtime, before sending the email.
Attach the image to the email. You can then reference it inline with cid:.
<img src="cid:logo.png" />
Use a data URI and inline the data:
<img src="data:image/x-icon,%00%00%01%00%01%00%10%10%00%00%01%00%20%00h%04%00%00%16%00%00%00(%00%00%00%10%00%00%00%20%00%00%00%01%00%20%00%00%00%00%00%00%00%00%00%13%0B%00%00%13%0B%00%00%00%00%00%00%00%00%00%00%00%00%00%00llm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FF%00%00%00%00%00%00%00%00llm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FF%00%00%00%00%00%00%00%00llm%FFllm%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00llm%FFllm%FF%00%00%00%00%00%00%00%00llm%FFllm%FF%00%00%00%00llm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FF%00%00%00%00llm%FFllm%FF%00%00%00%00%00%00%00%00llm%FFllm%FF%00%00%00%00llm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FFllm%FF%00%00%00%00llm%FFllm%FF%00%00%00%00%00%00%00%00llm%FFllm%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00Tx%9B%14Ox%A0%3CJx%A4dDx%AA%91Lx%A2%19llm%FFllm%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00Kx%A3%0F%3Cx%B1R%3Ex%B0%84%3Ex%B0%B9%3Ex%B0%DE%3Ex%B0%FF%3Fx%AF%FFAw%AD%FFBv%AB%FFDw%A9%3E%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%3Dx%B0*Ax%AD%FFAx%AD%FFAx%AD%FFBw%AB%ECEv%A9%C0Cw%AB%85%3B%7B%B3T*%83%C5R%15%8D%DCY%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%3Fx%AF%09Bx%ACsDv%AAQDv%AA%2B%3B%7B%B3%08%00%00%00%00%18%8C%D9%0C%09%93%E8r%03%97%EF%E2%02%97%EE%FF%00%99%F2%1B%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%09%93%E8%19%03%97%EE%82%03%96%EE%ED%05%95%EC%FF%04%97%EB%EC%09%91%EA%82%1Dx%E6N%20r%E9%02%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%0F%91%E1%02%02%97%EE%24%03%97%EE%86%05%96%EC%F3%06%95%EB%FF%06%95%EB%EB%04%98%EB%83%0D%8C%E9%10'm%E5L%2Fc%E4%FC.d%E4%81%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%04%96%ED%09%06%95%EB%D5%06%95%EB%FF%06%95%EB%E9%06%96%EB%7C%04%98%EB%17%00%00%00%00%2Bg%E46.d%E4%F8%2Cf%E4%F8%2Cf%E4D%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%06%95%EBl%06%95%EB~%05%96%EB%15%00%00%00%00%00%00%00%00-d%E4%22-e%E4%E5%2Cf%E4%FF%2Cf%E4X%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00.c%E4%0F%2Ce%E4%CB%2Cf%E4%FF%2Cf%E4%7B%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00.c%E4%02%2Cf%E4%AD%2Cf%E4%FF%2Cf%E4%A1%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00.d%E4%02%2Cf%E4%93%2Cf%E4%FF%2Cf%E4%C0%2Cf%E4%07%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%80%01%00%00%80%01%F0%BF%9F%F9%00%00%90%09%00%00%90%09%00%00%9F%01%00%00%E0%07%00%00%E0%07%00%00%E0%83%00%00%FE%01%00%00%F0%01%00%00%F0!%00%00%F8%C3%FF%FF%FF%87%FF%FF%FF%0F%00%00%FE%0F%00%00" />
You can use the data: URI Kitchen to create one like this, or just use base64 as per the spec.

Provide absolute path of logo image, such as
<img src="http://www.foobar.com/Content/logo.png" alt="DTD" style="float:left">
or Attach the image to the email.

Related

Is there any way to send HTML e-mail with embedded image in UWP

I am working on a uwp app to send html email with embedded image. I was using EASendMail nuget pakage and it was fine after some time my app shows error:
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond. (Exception from
HRESULT: 0x8007274c)
I think the trial period has expired what should I do?
using EASendMailRT;
https://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=8
I can't find any alternative
try
{
string ToAddress = MailSendPage.toAddressTxtBox;
string Subject = MailSendPage.subjectTxtBox;
SmtpMail oMail = new SmtpMail("TryIt");
oMail.From = new MailAddress(username);
if(!String.IsNullOrEmpty(ToAddress)&& !String.IsNullOrEmpty(Subject))
{
oMail.To.Add(new MailAddress(ToAddress));
oMail.Subject = Subject;
EASendMailRT.SmtpClient oSmtp = new EASendMailRT.SmtpClient();
SmtpServer oServer = new SmtpServer(host);
oServer.User = username;
oServer.Password = password;
oServer.Port = port;
if (IsStackPanalHasImg() == true)
{
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
string[] files = Directory.GetFiles(localFolder.Path + #"\ProjectImages");
foreach (string eachfile in files)
{
foreach (string name in covertToHtml.ControlName)
{
string pattern = string.Format("{0}.jpeg", name);
if (Regex.IsMatch(eachfile, pattern))
{
Attachment oAttachment = await oMail.AddAttachmentAsync(eachfile);
oAttachment.ContentID = name;
}
}
}
}
await oSmtp.SendMailAsync(oServer, oMail);
popUpMsgs.popup(" The Mail has been sent");
}
}
catch (Exception ep)
{
popUpMsgs.popup(String.Format("Failed to send email with the following error: {0}", ep.Message));
}
The built-in e-mail API only support sending plain text e-mail messages as Docs state:
This method only sends plain text messages. You can't set the body of the message to the HTML format.
What you can do is attach images to the e-mail:
EmailMessage mail = new EmailMessage();
mail.Sender = new EmailRecipient("test#example.com");
mail.To.Add(new EmailRecipient("someone#example.com"));
mail.Subject = "Hello";
mail.Body = "World";
var file = await StorageFile.GetFileFromApplicationUriAsync(
new Uri("ms-appx:///Assets/StoreLogo.png"));
mail.Attachments.Add(new EmailAttachment(file.Name, file));
await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(mail);
In addition, sending attachments works well only in case of the built-in UWP Outlook Mail client. Classic Outlook will most likely ignore the attachments altogether.
If you need to embed the image, you will need to use a e-mail service. I can recommend SendGrid or MailGun. Both have C# APIs which work like a breeze. They are also free for limited number of e-mails.
There are several ways you can embed the images in a HTML e-mail message.
The oldest is using CID (Content ID) which you were using in your question.
Second option is using Base64 encoding. You first turn your image into a Base64 string. There are many tutorials on this, for example in this blogpost. Then you can just embed the image in the src of your <img> tag:
<img src="data:image/jpeg;base64, YOURIMAGEINBASE64"/>
Finally you can embed an image which is hosted somewhere. This scales the best if you need to send the e-mail to many recipients, but of course requires actually hosting the image somewhere. Of the three methods it is also supported in most clients.
All three approaches are described in detail in this post.

EWS emails have base64 img tags encoded

Background context:
I'm using EWS Managed API 2.0 to connect to customer Outlook mailbox and process their emails into my application. I do not have control over what kind of emails the customers send, however part of the processing is maintaining the attachments and embedded images that are being sent.
My problem:
One of the users has sent an HTML type email with a base64 image as part of his signature. The Exchange Api gets the body of the email HTML encoded and part of the body, base64 images are encoded as well (converted the '+' sign to '& #43;'), which now breaks my application.
Question: Is there a way to retrieve the email body without having the base64 images encoded? As a workaround, right now I'm doing a string replace of '& #43;' to '+'.
This is part of the code I'm using to get the email body; The Assembly I'm using: Microsoft.Exchange.WebServices Version=15.0.0.0
var service = new ExchangeService(Exchange2010_SP2);
// rest of creating the service
var singleEmailView = new ItemView(1);
SearchFilter unreadEmailsFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
var emailResults = service.FindItems(WellKnownFolderName.Inbox, unreadEmailsFilter, singleEmailView);
if (emailResults.Items.Any())
{
var firstItem = emailResults.Items.First();
var email = firstItem as EmailMessage;
email.Load();
var propertySet = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent, EmailMessageSchema.IsRead);
service.LoadPropertiesForItems(new List<Item> { firstItem }, propertySet);
var body = firstItem.Body;
}
Doing email.Body or firstItem.Body retrives the same HTML.
This is an example of an email with encoded base64 image - see '& #43;' in img src:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<b>HIIIIIIIIIIIIIIIIIIIIIII <b><img src="data:image/gif;base64,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">
</b></b>
</body>
</html>

Office 365 API - Embed image

I am already successfully sending emails via the api. I now need to try and embed an image to the footer of the email.
I am running a wpf c# app and have loaded the image to my system and set it as content build type so I can get a handle on it.
The api requires a string as the body.
I have created an HTML email format via the stringbuilder class.
I am using the following code to try and embed the image.
sb.Append("<p style=\"text-align: left;\"> </p>");
var avHtml = AlternateView.CreateAlternateViewFromString(sb.ToString(), null, MediaTypeNames.Text.Html);
string path = Environment.CurrentDirectory + #"\images\fordEmail.jpg";
var inline = new LinkedResource(path, MediaTypeNames.Image.Jpeg);
inline.ContentId = Guid.NewGuid().ToString();
avHtml.LinkedResources.Add(inline);
sb.Append(String.Format(#"<img src=""cid:{0}"" />", inline.ContentId));
return sb.ToString();
The image appears on the email but as a dead link, red cross.
I'm not sure if I have to attach the image first or maybe render out to base64?
Any help would be gratefully accepted.
Thanks Scott
EDIT:
Code for API
mail.Subject = subject;
mail.Body = new ItemBody() { Content = body, ContentType = BodyType.HTML };
await client.Me.SendMailAsync(mail, true);
EDIT
Jason seems to be getting me along the right route. But I read somewhere that it may need saving as a draft and then sending.
My mail api code is as follows;
mail.Subject = subject;
mail.Body = new ItemBody() { Content = body, ContentType = BodyType.HTML };
await client.Me.Messages.AddMessageAsync(mail);
var messageId = mail.Id;
string path = Environment.CurrentDirectory + #"\images\fordEmail.jpg";
Image img = Image.FromFile(path);
byte[] arr;
using (var ms = new MemoryStream())
{
img.Save(ms, ImageFormat.Jpeg);
arr = ms.ToArray();
}
mail.Attachments.Add(new FileAttachment()
{
IsInline = true,
ContentBytes = arr,
Name = "fordEmail.jpg",
ContentId = "my_inline_attachment"
});
await client.Me.Messages[messageId].SendAsync();
and the page content (as requested)
<p><strong>Automated message from xxx.</strong></p><p>*Amendment from previous notification</p><style type="text/css">.tg {border-collapse:collapse;border-spacing:0;border-color:#aabcfe;}.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 50px 10px 10px;border-style:solid;border-width:0px;overflow:hidden;word-break:normal;border-color:#aabcfe;color:#669;background-color:#e8edff;border-top-width:1px;border-bottom-width:1px;}.tg th{font-family:Arial, sans-serif;font-size:14px;text-align-left;font-weight:normal;padding:10px 50px 10px 10px;border-style:solid;border-width:0px;overflow:hidden;word-break:normal;border-color:#aabcfe;color:#039;background-color:#b9c9fe;border-top-width:1px;border-bottom-width:1px;}p {font-family:Arial, sans-serif;font-size:12px}p.padding {padding-right: 50px}p.smallFont {font-size:9px}</style><p>Flight xxx has now arrived. Please find the details below; </p><table class="tg"><tr><th class="tg-031e" colspan="2" text-alight:left>Flight Details</th></tr><tr><td class="tg-031e"<p>Date</p></td><td class="tg-031e"<p class="DecimalAligned">07/05/2015</p></td></tr><tr><td class="tg-031e"<p>Flight</p></td><td class="tg-031e"<p class="DecimalAligned">xxx469J</p></td></tr><tr><td class="tg-031e"<p>Route</p></td><td class="tg-031e"<p class="DecimalAligned">DUB - FNC</p></td></tr><tr><td class="tg-031e"<p class="padding">Scheduled / Actual Time Departure</p></td><td class="tg-031e"<p class="DecimalAligned">07:10 / 12:00 (UTC)</p></td></tr><tr><td class="tg-031e"<p>Scheduled / Actual Time Arrival</p></td><td class="tg-031e"<p class="DecimalAligned">10:55 / 14:00 (UTC)</p></td></tr><tr><td class="tg-031e"<p>TOB</p></td><td class="tg-031e"<p class="DecimalAligned">100+1</p></td></tr></tbody></table><p class="smallFont"><em>Source: xxx</em></span></p><p>Comments : TEST </p><p>Should you require any further information please do not hesitate to contact us </p><p>Operations Manager<br>xxx<br>t +44 (0) 111 111 111 – H24<br>s xxx<br>e xxx</p><p style="text-align: left;"> </p><img src="cid:my_inline_attachment" />
Still no attachment.
Thanks
Yes, you have to attach the file, and be sure to set IsInline to true and the ContentId property to the same value you use in the HTML markup. See this post for the raw REST equivalent: How do I send Email with inline Attachments.
OK. I found the answer with the help of this stock overflow question.
Here
The key to this is the
// Update with attachments
await m.UpdateAsync();
// Send the message
await m.SendAsync();
Seems a problem with the API at the moment. Thanks for all your help on this. Hopefully this will help others out.
Scott

set image in email body using html c#

I know that thats not a new question but i want to know that when i set image in my Email Body using the below C# code, why my image not show on mail
SmtpClient client = new SmtpClient();
MailMessage myMessage = new MailMessage();
String Body = "<img src=\"images/logo2.png\" style=\"width:75px; height:75px;\" />";
myMessage.To.Add(new MailAddress(txtemail.Text));
myMessage.Subject = "Subject";
myMessage.Body = Body;
myMessage.IsBodyHtml = true;
try
{
client.Send(myMessage);
}
catch (Exception ex)
{
Response.Write("Unable to send Email" + ex);
}
I am using asp.net c#.
Email will be opened in an email client and doesn't know which web-application to access the image. So your image src shouldn't be relative to the application. Change the src to include the full url:
<img src=\"http://www.somedomain.nl/images/logo2.png\"
Test the url in a browser by taking the src value and try browsing it. If it doesn't work, the src value isn't retrievable.

Gmail inserts <wbr> tags into links

I'm trying to send an email that consists a link. But when I send it to gmail account it becomes broken with tags. Email has the base64 encoding.
Here is my html:
<p>Hello!</p><p>Here is the link to account activation:</p><p>Link</p>
And in gmail my link is displaying as:
<a>
"http://www.example.com/"
<wbr></wbr>
"admin/activate/"
<wbr></wbr>
"f8ekrwef2rnkjsdnfksjdnfskjnu3"
</a>
Can I prevent somehow insertion of these tags into my link by gmail?
Here is the full method with email generation:
private void ShareHtmlHandler(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "My email example";
request.Data.Properties.Description =
"Description for my email example";
string htmlExample = "<p>Hello!</p><p>Here is the magnet link to requested torrent:</p><p>magnet:?xt=urn:btih:539390D341F8C18400052ED905F77E48D6EBE40E&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=udp%3A%2F%2Ftracker.istole.it%3A80%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=http%3A%2F%2Fmgtracker.org%3A2710%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=http%3A%2F%2Ftracker.best-torrents.net%3A6969%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=http%3A%2F%2Fexplodie.org%3A6969%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=http%3A%2F%2Fbt.careland.com.cn%3A6969%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=http%3A%2F%2Ftracker1.wasabii.com.tw%3A6969%2Fannounce&dn=Avatar+ECE+(2009)+%5B1080p%5D&tr=http%3A%2F%2Fwww.eddie4.nl%3A6969%2Fannounce&xc=TorrentRTSearch</p>";
string htmlFormat = HtmlFormatHelper.CreateHtmlFormat(htmlExample);
}

Categories

Resources