Welcome! Log In Create A New Profile

Advanced

Image in email->Outlook

Posted by AadG 
Image in email->Outlook
April 24, 2020 06:31PM
Hi all,

Anyone figured out a way to put an image in a email, so this image is visible in Outlook ?
I.e. a companylogo.

Best regards,

Aad
Argus
Re: Image in email->Outlook
April 24, 2020 07:43PM
you need to prepare the email text as html, encode your image as a base64 chain, and use the appropriate html syntax to add it as such in your email... You can google all the details quite easily.
Re: Image in email->Outlook
April 24, 2020 07:55PM
Thanks Argus,

I'm using RTF-fields to compose the the with a mailmerge. When the merge is done I use RTFtoHTML and send the file by email This is working
very nice, but not for the image. Do you have any tips to put this to work, because I tried to put the logo into the RTF. This works but no logo in the Outlook mail.

Thanks for any help.

Best regards,

Aad
argus
Re: Image in email->Outlook
April 24, 2020 08:05PM
look at the html code you are sending, and specifically look at the html code generated for the image.
Once you have it, replace it by the CORRECT html code to send an embedded base64 image as specified above.
Re: Image in email->Outlook
April 24, 2020 09:40PM
Hi Aad,

I use EmailImportHTML() and that works for me.

	myEmail is Email
	myEmail..Sender = sSender
	myEmail..SenderAddress = sSender
	myEmail..Subject = szSubject
	myEmail..Message = szMessage
	IF Position(Upper(myEmail.Message),"<BODY") > 0 THEN
		
		// indeed this does not work 
// myEmail.HTML = myEmail.Message

// but this line does
		EmailImportHTML(myEmail, myEmail.Message, fCurrentDir())
		
		// plain text for emailcleint without HTML support
		myEmail.Message = HTMLToText(myEmail.Message)
	END

Arie
Re: Image in email->Outlook
April 25, 2020 11:45AM
Thanks Arie,

I read about EmailImportHtml but your example makes it more clear to me.

Best regards,

Aad
Re: Image in email->Outlook
May 01, 2020 12:44PM
Hey Arie

You wrote that you use EmailImportHtml

Do you really use this to send an image in an email with Outlook??

Could you make a little example ??

TIA !!!
Jan
Re: Image in email->Outlook
May 01, 2020 09:08PM
Hi Jan,

I'm sorry. I don't use Outlook but send the email directly using a mailserver

myEmail is Email
MySession is emailSMTPSession
...
EmailStartSession(MySession)
EmailSendMessage (MySession,myEmail,nEmailOption)

Arie
Re: Image in email->Outlook
May 02, 2020 11:45AM
Re: Image in email->Outlook
May 02, 2020 12:19PM
Hi Argus,

Can you put a small example of this CORRECT html code.

What I found on internet is not very clear.

I want to send images IN my email with SMTP

TIA
Jan
Argus
Re: Image in email->Outlook
May 02, 2020 12:55PM
30 seconds on google :
src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" />

the string after the base64, is the base64 encoded image...

So the only thing you have to replace in your html email is the SRC part of the image.
Re: Image in email->Outlook
May 02, 2020 07:19PM
Hi Jan,

I'm not sure, but I think what Arie meant is that you have to save your file into a html-file.
After that you use EmailImportHtml and that would do the trick. I didn't try this yet, but maybe this
is the way to do it.

Windev does not have a simple way to include a image into a mail that can be read by Outlook. Strange
because I think it's the most used emailclient worldwide (business). Instead we have to struggle to get a professional looking email.

I tried several options ( not Arie's) and every client accepts an image in the right way, but not Outlook. I looked into Argus's options, but it didn't worked either.. Maybe he (Fabrice) can give a working example but I doubt it.

Despite all the help nobody's has a working example at hand. Maybe I sound a bit negative, but all the suggestions cost me a lot of effort and no result.

JMTC.

Best regards,

Aad



Edited 13 time(s). Last edit at 05/02/2020 08:52PM by AadG.
Re: Image in email->Outlook SOLVED !!!
May 02, 2020 09:47PM
Hey Argus,

You're right, I found that too

I have an html file where the images are included as base64.
If I view this html file locally then it is perfect.
But when I import the file (emailimporthtml) and send it, I don't see the pictures (in Outlook).
Outlook then reports that the pictures cannot be found

Thats my real problem

------------------------------------------------------------------------------------------------------------

I solved the problem !!
Don't use the Email structure from PCSOFT !!!

Make your own variabele !

Mymessage is Email

MyHTMLText is string
MyHTMLText = fLoadText(HTMLBestand)
Mymessage.Sender = "aa@bbb.nl"
Mymessage.Subject = "test"
Add(Mymessage.Recipient,"xxxxxx@gmail.com")
EmailImporteHTML(Mymessage,MyHTMLText, HTMLMap)
Mymessage.Message = HTMLToText(Mymessage.HTML)

I send this with SMTP and now i see the images...smileys with beer



Edited 1 time(s). Last edit at 05/02/2020 10:28PM by jtadebruin@gmail.com.
Re: Image in email->Outlook
May 03, 2020 04:58PM
Hi Folks,

you can also use the report editor to create html files (HTML_WITHOUT_CSS), but only with Version 14-18.
We use it heavy in our document management sytem.
After Version 18 PC Soft destroyed something in the HTML format, so that tables are damaged. It works with all E-Mail clients (incl. Outlook).

BTW, PC Soft, please make an option to create Outlook-friendly-HTML-code !!!!!!!

regards Michael
Re: Image in email->Outlook
May 03, 2020 05:07PM
I made my correct HTM file with the new office Word controle
Just use DocToHTML

Jan
Re: Image in email->Outlook SOLVED !!!
May 04, 2020 11:50AM
Quote
Don't use the Email structure from PCSOFT !!!

I can confirm that. There is a difference in the built-in email-structure (former?) and the email variable (newer?)

Arie
Re: Image in email->Outlook SOLVED !!!
May 15, 2020 06:25PM
@Jan

I'm trying to apply your easy example, but when i try to send the message with:

EmailSendMessage(MyMessage)

i receive an error message and the email is not sent.
Probably, i'm doing something wrong.

Pls, can you post your complet code that works?
or send it to: gmspano at tiscali dot it

Thanks in advance
Gianni
Re: Image in email->Outlook SOLVED !!!
May 16, 2020 11:18AM
Hey Gianni

I send you an example with WETRANSFER

Good luck ! smileys with beer

Jan
Re: Image in email->Outlook
May 16, 2020 12:25PM
Hello Jan

Thank you very much smileys with beer

Gianni
Re: Image in email->Outlook SOLVED !!!
July 03, 2020 04:08PM
Hi,

In your example what does the variable HTMLMap contain - the patch to the folder containing the actual image file?

Thanks
Reg
Re: Image in email->Outlook
July 04, 2020 10:39AM
Hi Reg,

HTMLmap is the map where you saved the HTML-file like EmailImportHTML(MyHTMLText, "C:\Email"). (see the help EmailImportHTML)

Best regards,

Aad
Re: Image in email->Outlook
July 04, 2020 12:36PM
So folder rather than map I guess.

Thanks Aad
Ola
Re: Image in email->Outlook
August 08, 2020 08:44PM
Hi all,

I am also "upgrading" my age old email sending procedure, which is based on the old Email structure, and sent only plain text. Only problem I had with that, was that the sending failed in XP, but worked OK in Win7 and Win10.

Here I have read that, when sending HTML messages, the Email structure should not be used, and the newer Email variable should be used instead. But the direct inclusion of an HTML-formatted text seems to be some kind of problem (because Outlook behaves criminally and does not display inserted images) , and therefore it should be included in the message with the EmailImportHtml command.

I am now preparing the email message in an HTML edit control, so it is ready to be sent as HTML as such.

My question:

Is it really necessary to send the HTML-message to the email structure variable via a disk file!?!?!? In Arie's sample there was no saving the text first to a file. Still he "imported" it with EmailImportHtml, and there was the mandatory directory parameter "fCurrentDir()". Can somebody please explain all this to me, as I really feel like Winnie the Pooh hereconfused smiley.

Best regards
Ola
(Using WD23)
[2020-08-11: changed the overwritten "structure" to "variable"]



Edited 1 time(s). Last edit at 08/11/2020 06:37PM by Ola.
Re: Image in email->Outlook
August 10, 2020 11:02AM
Hi Ola,

I'm using Windev22 so there may be alternative ways of doing this now, but here's the code I ended up using which works for me. My main objective was to allow my users to specify formatted email signatures within my application and then to automatically incorporate them into all email messages sent from my application.

//set up email session variable
MySession.ServerAddress = gsemref:sEM_smtpserver
MySession.Port=gsemref:nEM_smtpport
IF gsemref:sEM_TLS="Yes" THEN MySession.Option = emailOptionSecuredTLS
MySession.Name = gsemref:sEM_name
MySession.Password = gsemref:sEM_password

//set up email message variablee
MyMessage.Sender = gsemref:sEM_sender
MyMessage.SenderAddress = gsemref:sEM_sender
Add(MyMessage.Recipient,gsemref:sEM_recipient)
Add(MyMessage.Cc,gsemref:sEM_cc)
Add(MyMessage.Bcc,gsemref:sEM_bcc)
MyMessage.Subject = gsemref:sEM_subject

MyMessage.ReturnReceipt = gsemref:bEM_ReturnReceipt
MyMessage.Priority = gsemref:nEM_Priority
StringToArray(gsemref:sEM_Attachment,arrAttach,";")
j is int = 1
FOR EACH sAttfile OF arrAttach
IF sAttfile = "" THEN CONTINUE
MyMessage.Attach[j].Name = sAttfile
MyMessage.Attach[j].content = fLoadText(sAttfile)
MyMessage.Attach[j].ContentType = "application/pdf"
MyMessage.Attach[j].contentdescription = ""
MyMessage.Attach[j].identifiant=sAttfile
j ++
END

sSigPath is string
MyHTMLText is string
HTMLMAP is string

//compose a filepath/name to contain the user's email signature.
sSigPath = CompleteDir(cConfiguration::c_documentpath) + TBUSER.UserCode + CLogin::m_sDatabase + "Signature.htm"
MyHTMLText = RTFToHTML(gsemref:sEM_message) + CR + fLoadText(sSigPath)
HTMLMAP = CompleteDir(cConfiguration::c_documentpath) + CompleteDir(CLogin::m_sUserName)

EmailImportHTML(MyMessage,MyHTMLText, HTMLMAP)

Cheers
Reg
Re: Image in email->Outlook
August 10, 2020 11:24AM
Hi Ola,

there is no need to use a disk file, see my working sample code below.

i give the user the option so write in a edit (html) control called html1 (case 1) or to use an existing html-file as mail body (case 3)

The mail is sent directly from my app; not using Outlook !!

regards, heinz

/////////////////////////////////////////////

EmailReset(MyMessage)


MyMessage.Sender = ACCOUNT.MailAddr
MyMessage.SenderAddress = ACCOUNT.MailAddr

MyMessage.Subject = EDIT_TOPIC



IF ftyp = 1 THEN // html control

MyMessage.HTML = HTML1

END

IF ftyp = 2 THEN // TEXT
MyMessage.Message = HTMLToText(HTML1)
END


IF ftyp = 3 THEN // file
prepareHTML()
EmailImportHTML(MyMessage,MyHTMLText,mypics)
// Email.HTML = HTML1
END
Ola
Re: Image in email->Outlook
August 11, 2020 06:56PM
Hi Reg & Heintz

Good samples are always worth their weight in gold - Thank you!

@Heinz: Seems that your ftyp = 1 is the way to go in my code, that is, to move the HTML edit control directly to the email variable.

Then it seems that I also have to install/test also Outlook in my test machine to be able to see how it behaves, when the recipient is using Outlook and the HTML message contains images.

Best regards
Ola
(Using WX23)
Re: Image in email->Outlook
November 17, 2020 11:15AM
Hello,

I tried all the options above but no image in my mail message... eye rolling smiley I have an html edit box where the user can put a message with image and safe this the database or in an html file. (Choose the best option) Then want to send this with direct smtp. Everything works but no image is visible.
Is there anyone with an example for me?

Thanks!
Sammy
Re: Image in email->Outlook
December 01, 2020 02:11PM
For me was the trick to use EmailImporteHTML(MyMessage,MyHTMLText AFTER MyMessage..Attach
then it works ok, but when i use first the importhtml line and then the attach line it was not working.

Best regards,
Sammy
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: