CI am using MVC.ActionMailer to send emails from my website. I am having issues with embedding an inline image into the email.
Here is my Controller Action
public EmailResult WelcomeEmail()
{
WelcomeMailVM welcomeDetails = new WelcomeMailVM()
var path = HttpContext.Current.Server.MapPath("~/Content/images/myImage.png");
Attachments.Add("myImage.png", System.IO.File.ReadAllBytes(path));
//Attachments.Inline["holidaymate.png"] = System.IO.File.ReadAllBytes(path);
To.Add("someEmail@test.com");
From = "noreply@myDomain.com";
Subject = "Welcome to My Site;
return Email("WelcomeEmail", welcomeDetails);
}
and the view for the email
@model HolidayMate.API.ViewModels.Mail.WelcomeMailVM
@using ActionMailer.Net.Mvc
@{
Layout = "~/Views/Shared/_MailLayout.cshtml";
}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<table cellpadding="0" cellspacing="0" border="0" id="backgroundTable">
<tr>
<td style="width:300px">
@Html.InlineImage("myImage.png")
</td>
<td style="width:300px">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Date</td>
<td>@DateTime.Now.ToString("dd MMMM yyyy")
</td>
</tr>
</table>
</td>
</tr>
</table>
The email sends perfectly. But the image is not displayed in the email. I get this issue with gmail and with thunderbird. Unfortunately I do not have outlook to test on. When googling i found the following
#38 Inline images are not displayed in Thunderbird
But i am not sure where to send the content type for the email. Please any help would be greatly appreciated.
I used the MVC Mailer instead of the ActionMailer. Now the images works fine.
But now i can’t sent the email unless i use the following SMTP Settings, my normal settings does not work
Does not work, but when using the following it works