Insert an image in HTML mail sent from Shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert an image in HTML mail sent from Shell script
# 8  
Old 12-30-2014
You can include the image data in the mail using HTML's embedded img url eg.

Code:
<img width=640 height=147 src="data:image/jpeg;base64,$(base64 /home/u35731/dev/1.jpg)">

This User Gave Thanks to Skrynesaver For This Post:
# 9  
Old 12-30-2014
Hi Skrynesaver
I tried the below after you suggested but still i dont see the image in mail Smilie

Code:
<img width=640 height=147 src="data:image/jpeg;base64,$(base64 /home/u35731/dev/1.jpg)">

In email, I'm getting just a cross image saying "the linked image cannot be displayed"

Thanks and advanced happy new year
Anji
# 10  
Old 12-30-2014
It's probably the "+" characters in the base64 encode they may need to be URI encoded try:

Code:
<img width=640 height=147 src="data:image/jpeg;base64,$(base64 /home/u35731/dev/1.jpg | sed 's/+/%2b/g')">

# 11  
Old 12-30-2014
Hi Chubler
Unfortunately still no luck Smilie

Please suggest if i am missing something here

Code which is not working
Code:
<img width=640 height=147 src="data:image/jpeg;base64,$(base64 /home/u35731/dev/1.jpg | sed 's/+/%2b/g')">

Code which is working
Code:
<img width=130 height=30 id="Picture_x0020_4" src=http://i.imgur.com/4pGDdQM.gif >

Thank you
# 12  
Old 12-31-2014
Do you have base64 installed and in your path?

Try running the encode from the command line and see if you get output eg:

Code:
$ base64 /home/u35731/dev/1.jpg
8I+xMods90y4ayTcU8uKPKpTJTaOY6A9eofuLRNTi7wfIR8Rp5CPVCQcXWEFOdKd6p0HEvYdi/YK
v3dfllPLGVezEMm1PFW8C7qEPEHaeNM6PwHZ4+QnU27m4PESHUT0CAj+kc6u3q9W42WRpgcx7yFm
...
fP35+vP15+vP/9yf/z90FwlRAFggAA==

This User Gave Thanks to Chubler_XL For This Post:
# 13  
Old 01-01-2015
Wish you a happy new year to all the experts

Hi Chubler
Yes base64 is installed in my path, see the result from the commandline

Code:
$ base64 /home/u35731/dev/1.jpg
/9j/4RdARXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAA
agEoAAMAAAABAAIAAAExAAIAAAAeAAAAcgEyAAIAAAAUAAAAkIdpAAQAAAABAAAApAAAANAAD0JA
AAAnEAAPQkAAACcQQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykAMjAxNDowNzoyOCAxMDox
MjowNgAAA6ABAAMAAAAB//8AAKACAAQAAAABAAADBKADAAQAAAABAAAAsQAAAAAAAAAGAQMAAwAA
----

anF1ZXJ5LmZpbGVEb3dubG9hZE9yZGVyLmpzPzE0MDQ5MDYwMDQiIHR5cGU9InRleHQvamF2YXNj
cmlwdCI+PC9zY3JpcHQ+CjxzY3JpcHQgc3JjPSJ0eXBvM2NvbmYvZXh0L2p1bGl1c2JhZXJfaW1h
Z2VkYi9SZXNvdXJjZXMvUHVibGljL0phdmFTY3JpcHQvc29sci5qcz8xNDA0OTA2MDA0IiB0eXBl
PSJ0ZXh0L2phdmFzY3JpcHQiPjwvc2NyaXB0PgoKCgo8L2JvZHk+CjwvaHRtbD4=

# 14  
Old 01-04-2015
Good Morning Experts
I triped multiple ways but still unable to find the solution...
Can some one help me out here please

Thanks In Advance
Anji
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A shell script for checking the last image and sending it in attachment to mail

Hello every one. I use mutt : "mpack -s "Test" /home/pi/Pictures/2018-10-05_23_10_40.jpg my_email_addres " to send me a particular picture with the name of the data+jpg in a pictures folder, but this folder I use it for a timelapse proyect with more pictures , and what I need is... (2 Replies)
Discussion started by: maxbcn
2 Replies

2. Shell Programming and Scripting

Embed image to the html script

hi, trying to embed an image to the html file to send out as an email. img src="data:image/jpeg;base64,$(base64 /home/test/abc.jpg but getting error as file not found after it aplies base64 on the file. (8 Replies)
Discussion started by: ATWC
8 Replies

3. Shell Programming and Scripting

Script that gathers specific values from files and puts it into HTML to send e-mail

Hi All, Sorry for long topic here. So the drill goes like that, I need a script which gathers different values from different files/locations. A_CT=`cat a.dat | awk -F'|' '{print $1}' >> report.txt` B_CT=`cat b.dat | awk -F'|' '{print $3}' >> report.txt` C_CT=`cat c.dat | awk -F'|'... (4 Replies)
Discussion started by: shivakid
4 Replies

4. Shell Programming and Scripting

[Solved] Shell script output in HTML or with table like results and mail

Hello, Currently i have a script which will disply the results in plain text format. I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html and send that content as email. Please help me how i can do that. I am using... (10 Replies)
Discussion started by: joy lobo
10 Replies

5. UNIX for Dummies Questions & Answers

Bash script to insert data into an html table

hi, I need to create a bash shell script which picks up data from a text file and in the output file puts it into an html made table. I have to use sed and awk utilties to do this the input text file will contain data in the format: job name para1 para2 para3 para4 para4 1 ... (1 Reply)
Discussion started by: intern123
1 Replies

6. Shell Programming and Scripting

Send mail with rich text / HTML with image

Hi, Is it possible to send mail from my HP-Ux system with images, rich text? I would like to program in such a way that I have my company's logo(.jpg) image attached in the mail geeting triggered. I would like to send a rich text/HTML email instead of plain text mail to the recipients. Is it... (2 Replies)
Discussion started by: rythym05
2 Replies

7. UNIX for Advanced & Expert Users

shellinabox/html help to insert a keypress with an html button

I am trying to use shellinabox as a terminal emulator. Everything is working except there seems to be no way to simulate an F14 button press in shellinabox. I am already embedding shellinabox in an html page so Im am wondering if there is a way to make an html/js button that will pass F14 to the... (0 Replies)
Discussion started by: syadnom
0 Replies

8. Shell Programming and Scripting

background image not loading in newly thrown html page by shell script

I m trying to throw back html page when a file is found.While throwing back html page, the background image is not coming. I am using Apache server.Please suggest how to resolve... #!/bin/ksh echo -e "Content-type: text/html\n\n" echo "<html><head></head><body background=\"/asc/ppp.jpg\">"... (10 Replies)
Discussion started by: ravi18s
10 Replies

9. Shell Programming and Scripting

Script to Convert HTML to MIME mail -- HELP!

Hi: I have writed a script that read a HTML file and convert this in a multipart mime fail to send in a mail. But the result isn't interpreted lika a mime file!! Somebody can see the error??? --------------------------- #! /bin/bash SB=$1 IF=$2 OF=$3 rm -f $OF.b64 ... (7 Replies)
Discussion started by: sushisan
7 Replies

10. AIX

Command line/Script to send E-mail with HTML body and binary attachment

I apoligize for the cross-post but I'm not getting much in the way of help in the dummies forum: I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command... (3 Replies)
Discussion started by: G-Man
3 Replies
Login or Register to Ask a Question