Mail with HTML

Questions and answers on developing, deploying and using plugins and JavaBeans

Mail with HTML

Postby andres_achiary1363801637 » Thu May 22, 2014 7:39 pm

Hi, all

I want to send emails using the mail plugin of Servoy and I'm having trouble with sending a message with html tags. What I really want to do is to send an inline image in the message and I found this tip but it didn't work: http://www.mindfiresolutions.com/Adding-Inline-Images-to-the-body-of-your-mail-in-Servoy-359.php

I receive the mail like a normal text message with all my html text in it. What am I missing to do this??

Thanks, Andres

My message is:
Code: Select all
   <html><a href="http://www.infocomsa.com.ar/files/folleto_prode.html">Si no puede ver el mail correctamente, haga clic aqui</a></html>
   <html><img src="%%folleto_prode.png%%"</html>
andres_achiary1363801637
 
Posts: 6
Joined: Wed Mar 20, 2013 7:47 pm

Re: Mail with HTML

Postby sovanm » Fri May 23, 2014 8:53 am

Hi Andres,

I tried this code and it worked for me.

Code: Select all
   
   if(plugins.mail){
      
      var properties = new Array();
          properties[0] = 'mail.smtp.host=smtp.gmail.com';
          properties[1] = 'mail.smtp.port=587';
          properties[2] = 'mail.smtp.auth=true';
          properties[3] = 'mail.smtp.username=<yourID>@gmail.com';
          properties[4] = 'mail.smtp.password=<your_password>';
          properties[5] = 'mail.smtp.starttls.enable=true';
          
          var attach1 = plugins.mail.createBinaryAttachment('flower1.jpg',plugins.file.readFile('c:/temp/flower1.jpg'));
          var attach2 = plugins.mail.createBinaryAttachment('flower2.jpg',plugins.file.readFile('c:/temp/flower2.jpg'));
          
                // Here is the HTML code you need to write.
           var msgText = ' <HTML>This is some HTML Texts. Here, I am adding my image inline.'+
         ' <BR> <IMG SRC="%% flower1.jpg %%">'+
         ' <BR> My another image.'+
         ' <BR> <IMG SRC="%% flower2.jpg %%">'+
         ' </HTML>';
         
           var success = plugins.mail.sendMail('sovanm@mindfiresolutions.com', <yourID>@gmail.com', 'Mail with HTML inline image', msgText,null,null,new Array(attach1, attach2),properties);
           if(!success)
           {
                 plugins.dialogs.showWarningDialog('Alert','Failed to send mail','OK');
           } else {
              
                plugins.dialogs.showWarningDialog('Alert','Success','OK');
           }
   }


I tried it with gmail SMTP settings.

Hope this helps you.

Thanks
sovanm
 
Posts: 99
Joined: Fri Oct 28, 2011 1:55 pm
Location: Bhubaneswar, India


Return to Plugins and Beans

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 5 guests