Give link with href in mail - rails4 - html

Here I used job and service to send a mail to users. Now I want to send our app link with mail as a play store image. I totally done with gmail account. But for a outlook users, the image does not display. What I was done is, in mailer
def course_mailer(email, title, description)
mail(:bcc => email, :subject => title) do |format|
format.html { render html: '<div class="text-center" style="margin-top: 60px;">'
"#{description}" '<br>
<a href="https://play.google.com/store..." target="blank">
<img alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" style="height: 75px;"></a>
</div>'.html_safe }
end
I call this method in my service as,
CourseMailer.course_mailer(#delivery[0].emailIds, #delivery[0].title, #delivery[0].description).deliver_now!
This service correctly called when a mail send to gamil domain. The image source doesnot display when the mail sent to outlook users. The change done in html is,
in gmail,
<img alt="Get it on Google Play" src="https://ci5.googleusercontent.com/proxy/SIiw9QYZvvWkjPnHXXOtNDZOQSVfteW0xFkeVVgT--Mz5VwUkdd1Cy64y5G9geRByBkoHWsDjnWXg5apnUVsQgykWcnVZKHCCU44Us1cjWtNfibbBrzOl3XO3FLu8fn8dGmE0tJnqA=s0-d-e1-ft#https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" style="height:75px" class="CToWUd">
in outlook,
<img alt="Get it on Google Play" style="height:75px" blockedimagesrc="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png">
The img src(gmail) changed into image blockedimagesrc(outlook).How can I get the img src to display an image in outlook also.

Images are blocked by default except for trusted senders. When images
are blocked, there are two options displayed at the top of the email:
“To help protect your privacy, some content in this message has been
blocked. To re-enable the blocked features, click here.”
“To always show content from this sender, click here.”
When either option is selected, images display. If you choose to “always show content from
this sender,” images will automatically display from that sender
moving forward.
Source: https://litmus.com/blog/rendering-css-support-more-in-office-365s-outlook-web-app

Related

How to send personalized links in a mail?

I'm setting up a solution for a backoffice website where the user should be able to send mail for some technician.
In this mail, the technician must be able to click on a specific button and this will open a new web page with adaptative parameters such as the date, the address, the client name, etc..
To do so, I need to send at least one parameter in the mail (the mission id of this technician) and this parameter must be different in each mail.
I already tried a solution in which the mail is written in HTML and then I could insert a form in the body or a link for a GET request. But it seems that not all the mail server can handle this way of work.
In Gmail it works for everything, but using Safari for Mac OS X, or Outlook messenger it doesn't.
Using POST:
<form action='__the_website_to_post_request__' method='post'>
<input name='id' type='hidden' value='$id'>
<button type='submit' formmethod='post'>Upload reports</button>
</form>
Using GET:
<a href='__the_website_to_post_request__?id=".$id."&tok=".md5($id)."'>
Upload reports
</a>
In Outlook, no button appears and in Safari, the post method doesn't work.
Maybe another solution exist doesn't matter which mail application I should use ?

Gmail not showing embedded images in email

I've been looking at different threads online and here at SO discussing embedding images into email and why they don't always send the image. I'm embedding a base64 encoded string into an img tag and gmail is rejecting it. When I inspect the email the img src attribute is empty and some info has been added to the 'a' tag that represents it's parent element. I made sure to set my gmail setting to include external images! When I look at outlook.com emails they do send the image.
I've read that the email and image must come from a public server? Currently I'm sending the email from my localhost running iis (because I'm testing) and using sendgrid to send my emails.
Can anyone give me more advice on getting the image to display in my email in gmail's service?
FYI - Here is how I'm constructing the image tag. I've included different attributes in the img tag to get it to show but none of these attributes have worked for gmail. I also use '#Raw' because I'm constructing my email with razore engine nuget package and 'Html.Raw()' doesn't work with Razore Engine! The email text looks good before I send it to sendgrid for mailing it off and I see it image in outlook so I know the body is good.
<a href="www.mysite.com/Space/Public/#Model.SpaceId" target="_blank" class="thumbnail" style="margin-bottom: 0px;">
<img alt="SpaceImage" title="Space Image" style="display: block" width="225" height="225" src="data:image/jpg;base64,#Raw(Model.SpaceThumbnail)" />
<div class="caption">
#Model.SpaceName
</div>
</a>
Whenever we are sending emails, we have to embed the image for it to render successfully in most email clients including gmail. For asp.net it would be something like this:
string html = #"<html><body><img src=\"cid:imageId\"></body></html>";
AlternateView view = AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html);
LinkedResource imageResource = new LinkedResource("yourImagePath", MediaTypeNames.Image.Jpeg);
imageResource.ContentId = "imageId";
view.LinkedResources.Add(imageResource);

Hyperlink in outlook which will open new mail with image embedded in body

Outlook : 2013
I need to send mail to client with hyperlink in the body tag.As soon as client clicks on the hyperlink, new mail should be opened with some auto filled details like subject,to address and image in the body (most important thing).
simple use case: sending birthday mailers . as soon as we click on hyperlink, new mail should be opened with toaddress, subject and image in the body auto present so that we can just click the send button.
Can you please let me know how to achieve this ?
mailto only handles plan text body and subject. No HTML or attachments.
You can create an EML file (which is text) and make the user open it instead - Outlook will be happy to display the message with all its attachments and HTML body. To make sure Outlook displays the message in the unsent state, set the X-Unsent MIME header to 1.

Ruby ActionMailer. Why are my images getting blocked by email clients like Yahoo?

So I am trying to send an email on my ruby on rails app using ActionMailer. However, my images keep getting blocked on yahoo with this message "This message contains blocked images. Show Images Change this setting".
Is it because I am using:
<%= image_tag("headerforemail.jpg", :alt => "header") %>
Should I use:
<img src="images/headerforemail.jpg" alt= "header") >
Thank you!
Like was mentioned in the comments, quite a few email services by default will block images, unless the user has other wise set it to do other wise. So this is not an issue of your code not working. For a some what comprehensive list of email services and there image settings see the chart here

How to display image in html email message?

I'm writing a j2ee application, that generates an html and sends it as email. In my html, a have an image, but it is not displayed when email is received. The html code is something like:
<img src="myimage.gif"></img>
where "myimage.gif" is sent as attached file in the email.
I tried to change it to
<img src="cid:myimage.gif"></img>
but still no result. Any ideas?
It should be without a link to the image.
You should upload your image to you server and reference that as a hard coded url in the src
e.g. upload to myserver.com/images/myimage.gif the in your html
<img src="http://myserver.com/images/myimage.gif" />
Take a look at Commons Email. It's build on top of the Java Mail API but simplifies it.
They have an example for sending html mails with inline images http://commons.apache.org/email/userguide.html
import org.apache.commons.mail.HtmlEmail;
...
// Create the email message
HtmlEmail email = new HtmlEmail();
email.setHostName("mail.myserver.com");
email.addTo("jdoe#somewhere.org", "John Doe");
email.setFrom("me#apache.org", "Me");
email.setSubject("Test email with inline image");
// embed the image and get the content id
URL url = new URL("http://www.apache.org/images/asf_logo_wide.gif");
String cid = email.embed(url, "Apache logo");
// set the html message
email.setHtmlMsg("<html>The apache logo - <img src=\"cid:"+cid+"\"></html>");
// set the alternative message
email.setTextMsg("Your email client does not support HTML messages");
// send the email
email.send();
If the image is small enough, you could use my HTML Table pixel format :)
see my blog for details: HTML Table Pixel Format
This is just plain valid HTML, however it renders as an image.
/end of shameless plug