I'm trying to send an email with a template using springMvc. I used Velocity to disay the template. The problem is that the image in the cannot appear in my email. And I'm sure that my src is incorrect!
Here is my template.vm
<html>
<body>
<h3>Hi ${user.login}, welcome to the Chipping Sodbury On-the-Hill message boards!</h3>
<img src="fond-bleu.jpg">
<div>
Your email address is ${user.emailAddress}.
</div>
</body>
</html>
Your problem has nothing to do with Velocity, and I'm pretty sure your URL is not correct:
When displaying an image in an email, you have to choose between three solutions:
hosting the image somewhere (then the image URL will be something like http://myserver/...)
linking the image as an email attachment (in which case the image URL will be something like cid:{0})
embedding the image in base64 (in which case the image URL will be something like data:image/jpeg;base64,...).
There are pros and cons for each method.
Related
I am using Firebase Dynamic Links REST API to generate short links.
If I paste that link into the browser it redirects and loads the appropriate image. But when I use the same link to load image in <img> tag in my webpage it fails.
I created a sample(codesandbox link below) trying to load the same image. I put two image tags, one with bit.ly shortener and one generated with the firebase dynamic links generator. The bit.ly link loads fine.
Sample codesandbox : https://codesandbox.io/s/using-img-tag-forked-ufnd31?file=/index.html
Sample short link for a image : https://files.flux.chat/vs4fy3cY7s1aMnS57
Create dynamic link payload
URL : https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=WEB_API_KEY
BODY : {
"dynamicLinkInfo": {
"domainUriPrefix": "https://files.flux.chat",
"link": "https://firebasestorage.googleapis.com/v0/b/fluxchathq.appspot.com/o/business%2F5Nmu0449tlNVWVdOpo8h%2Fincoming%2FNA?generation=1654498929454543&alt=media&token=664c135f-48f3-4de8-8ba7-d75ca3a5362f",
"navigationInfo": {
"enableForcedRedirect": true
}
},
"suffix": {
"option": "UNGUESSABLE"
}
}
HTML code
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<div>
<img class="image" src="https://files.flux.chat/vs4fy3cY7s1aMnS57" />
<img class="image" src="https://bitly/3Lr8Bq1" />
</div>
</body>
</html>
I don't have any experience with this, but I think shortened urls won't work as an image source-- they don't point to an image directly, they redirect to an image.
Here's an old answer that seems relevant: https://stackoverflow.com/a/27062627/954986
That is not possible unless you own the domain where you want the shortened URL. For example, to do that, you would need to own (or have access to) the website bit.ly.
bit.ly is not hosting your video or your image, it only redirects them to the real URL when you click on the link.
[...]
You will see that your image is NOT in the code. It only redirects to the page that DOES contain your image.
Perhaps you could make an XHR request in javascript, and see if it returns a 3** status with some other location, and use that as the source for the image? (edit: the short link doesn't have CORS enabled, so this probably won't work)
I just tested with curl (well, httpie which is far superior), and the sample shortlink you provided gives a 302, with the Location response header being the actual image.
edit: I tested your sandbox, and the flux.chat image source shows a GET request resulting in a 403 Forbidden status code in the browser console. Maybe it's because it's being called from localhost? But firebase sees something about the request it doesn't like (maybe origin being localhost, maybe it being in an image source, maybe ..?) and that's preventing it from loading.
Sorry I don't have anything more concrete for you, definitely a strange issue.
Question
Can a web app display a G Suite user's profile image using just the thumbnailPhotoUrl, or is it necessary to save and serve the image?
Context
This Guide describes how to get the image from the Directory API. But I'm not sure how to move from the get request to an image file I can display. There is mention of the Closure Library to use for Base64 encoding/decoding.
I'd like to use a link to the image, to use as the src of an img element.
What I've Tried
A firebase cloud function using a service account with domain-wide delegation is retrieving user data via https://www.googleapis.com/admin/directory/v1/users. This returns the thumbnailPhotoUrl, and I'm able to paste the URL into chrome and view the image. If I share the thumbnailPhotoUrl with someone else, they do not see the image but see the silhouette placeholder instead.
Note: the thumbnailPhotoUrl includes /private like this:
https://www.google.com/s2/photos/private/xyz123...
Is that a clue that this URL will not work in the web app to display the image?
You can embed the contents of the URL directly into your HTML document. It looks like this:
<img width="16" height="16" alt="star" src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" />
The magic part is taking the image binary data and base-64 encoding it for the img tag.
The format of the above example:
data:[<mime type>][;charset=<charset>][;base64],<encoded data>
This link provides more details and shows how to do this.
Home page- I have more than the HOME PAGE and for some reason, the logo picture does not appear on the other pages. Do you have any idea how to fix that?
sample page
whenever i try to fix for another page the previous one gives the same problem.
<body <?php body_class(); ?>>
<div id="page" class="hfeed">
Hello from header.php
In short, the browser isn't displaying the image because the browser can't find it using the instructions you gave it. Those instructions are the src attribute of the img tag...
Now, there are a few possible reasons why the browser cannot find the image. You might have one problem going on, or all of them. Let's go through the following exercises to see if maybe we can narrow down the problem.
First, try putting the image in the same folder as your HTML document
his is the simplest way to insert an image. As long as everything is in the same folder, things are pretty simple to find.
Possible snags?
Simple (but common) typo: scr= instead of src=
Mispelling the image name: src="mypick.gif" or src="my pic.gif" instead of src="mypic.gif"
Wrong extension: src="mypic.jpg" when your image is a gif... mypic.gif. (Should I use gif or jpg? You might find this interesting.)
Malformed img tag...
Before going on to other possible reasons for your missing image, make sure that you can successfully insert an image as shown above.
I have an image stored in SPIFFS
When I launch the browser and put in the esp8266 IP address/images/image.jpg I can see the image. The image also shows in the index.html page in the root.
When I generate a page with
server.send(500, "text/html", "<head><title>esp8266</title></head><body><div id=\"banner\"><img src=\"/images/image.jpg\" width=\"900\" height=\"295\" /></div> <div id=\"page\"></body</html>");
The page does not show the image, just a image placeholder. AND I can no longer access the image via IP address/images/image.jpg. I'm thinking that server.send() changes the context of the root.
Thank You for any help.
First thing that I would do in this situation is try to serve that html page as a static file and see if it works. For example
server.serveStatic("/index.html", SPIFFS, "/static/index.html");
Or maybe this all happens just because of malformed HTML.
<div id=\"page\"></body</html>
I want to send an email with attachments using CDONTS. But, here is what i am using:
CDO_MAIL.AttachFile "http://SampleWebSite.com/Sample.asp?COMMAND=6"
In JavaScript we are doing:
image1.src = "http://SampleWebSite.com/Sample.asp?COMMAND=6"
The problem is - I do not have the exact image name. The above URL returns me an image. Can you please let me know how to resolve this ?
Thanks
Diodeus is correct. However, another way to "solve" this is to download the file so you have it locally and then attach it. Embedding in the HTML, as suggested by Diodeus, will cause most mail clients to block the image and require user interaction to download the image. It's better to do it attach it and reference it by CID.
CDO does not support HTTP. It's expecting a local file reference (C:....).
You can embed the image in the message body though, using simple HTML:
<img src="http://SampleWebSite.com/Sample.asp?COMMAND=6" />