jpg or HTML on email body

Hi,
I need send emails when the jpg or html are on email body.
When I send email, all is ok but the jpg or HMT on email body don´t sent.
What I refer to the jpg or html for this to be sent?

Thanks

Hi JuanMartin,

This is a sample of how you can send a email with a inline image

var attachment1 = plugins.mail.createBinaryAttachment('embeddedImage',plugins.file.readFile('c:/nok.jpg'));
var msgText = 'plain msg<html>styled msg<img src="%%embeddedImage%%"></html>';
var success = plugins.mail.sendMail('tsdsddd@gmail.com', 'John Cobb <from_me@example.com>', 'subject', msgText,null,'unnamed@example.com',[attachment1]);
application.output(success)

Is there any way to get something like this to work in a html area?

What do you mean by getting something like this to work in a html area?

Maybe all you need is a method using this kind of code and add a link to trigger it?

<a href="javascript:sendEmailMethod()">send as email</a>

Sorry, I ment inline images in a HTML area.
What we’d like to have is a crossplatform solution to display images in a HTML area, while the images are just in a shared folder on a clients fileserver. The difficulty of course is the path which will be different for mac and windows.
As replacing won’t work in a mixed environment my thought was have an inline image solve this problem.

Doesn’t this work for you as a provider for a text field with displayType = HTML_AREA?

var img = '<html><body><img src="media:///myInlineImage.gif"></body></html>';

[EDIT]
Sorry Marc, I just realize what you meant.
I just tried it and it works fine in developer and server smart and web clients (quick and dirty example, you might want to add error handling):

var img = getMyInlineImageData(); // variable shoud be of type MEDIA!

function getMyInlineImageData()
{
    var filePath = (application.getOSName().indexOf("Mac") > -1) 
                         ? "/user/lib/etc/myMacImage.png" 
                         : "C:/mywindowspath/public/myWinImage.png";
    return plugins.images.getImage(plugins.file.readFile(filePath)).getData();
}

Then you can use this form variable as a dataprovider for an image on your form (whithout using html).

Hope this helps,

Hi Patrick,

thnkx for your example. This works fine for getting the image into a media field, but I’d still need to have it in a html area as I want to be able to type text as well.

Any idea how to take this last step?

sanneke:
Hi JuanMartin,

This is a sample of how you can send a email with a inline image

var attachment1 = plugins.mail.createBinaryAttachment('embeddedImage',plugins.file.readFile('c:/nok.jpg'));

var msgText = ‘plain msgstyled msg’;
var success = plugins.mail.sendMail(‘tsdsddd@gmail.com’, ‘John Cobb from_me@example.com’, ‘subject’, msgText,null,‘unnamed@example.com’,[attachment1]);
application.output(success)

If I would like to send mail with a inline image from my servoy media library, then How can I do that?

var attachment1 = plugins.mail.createBinaryAttachment('embeddedImage', plugins.file.readFile('media:///myimage.png'));

Is not working…

Thanks.

To embedd images, more work is needed when the actual message is created. In the src tag of your image a reference to the relevant attachment has to be set and the header of the attachment has to be modified to not have it show up as an attachment. I don’t think you can do that with Servoy’s mail plugin. I know, however, that you can do that with our MailPro plugin :D . There is a demo available, so you can check that out. If you have questions regarding this functionality, please contact us directly.