By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,846 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,846 IT Pros & Developers. It's quick & easy.

javascript: initiating email and embedding image to the email in IE and Mozilla

P: 5
I have a requirement
When i click on button, i have to initiate an email with the to address, subject, and body should contain an image and the text .

Problem : I cannot embed the image using 'mailto' (javascript) . Please provide solutions for embedding image to the outlook or any email generator like outlook(if not present).

Thanks in Advance.
Oct 22 '08 #1
Share this Question
Share on Google+
7 Replies

Expert Mod 15k+
P: 16,027
I don't think this will be possible with JavaScript. I would recommend using server-side code to send email.
Oct 22 '08 #2

P: 5
is there any possible solution through client side. Server side i dont want because when the user clicks on button in his browser, outlook should open. If i do server side , then it will open in server not client side.
Oct 22 '08 #3

Expert Mod 15k+
P: 16,027
Giving control to the client to send mail is always unreliable. Not all users have email properly set up on their computer. See how webmail works. The user can enter the message, attach files, include images, etc. then when they click 'Send', the email is sent from the server-side.

If, however, you have a select user-base and you know that all users will have Outlook installed and set up, then you could depend on mailto. As for the image, you can't embed it as such using JavaScript, but you can provide the full URL to the image in the email body.
Oct 22 '08 #4

P: 5
Expand|Select|Wrap|Line Numbers
  1. var outlookApp = new ActiveXObject("Outlook.Application");
  2.             var nameSpace = outlookApp.getNameSpace("MAPI");
  3.             mailFolder = nameSpace.getDefaultFolder(6);
  4.             mailItem = mailFolder.Items.add('IPM.Note.FormA');
  5.             mailItem.Subject=Subject;
  6.             mailItem.To = ToAddress;
  7.             mailItem.HTMLBody = "image  here"+"<br><p><font face=Arial size=2>"+"BodyHi"+"<br>"+Bodypara1+"</p><br><br>"+footerregards+"</font>";
  8.             mailItem.display (0); 
this works in IE , Can I get equivalent code for Mozilla?
Please help in this regard. or any optimal solution for both the browsers?
Oct 22 '08 #5

Expert 100+
P: 1,208
There isn't an equivalent in Mozilla... activex is IE only
Oct 22 '08 #6

P: 5
is there any possible solution other than Activex through client side?
Oct 23 '08 #7

Expert Mod 15k+
P: 16,027
Add a HTML <img> tag within the body and point to a web URL.
Oct 23 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.