Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 3 Jahren, 1 Monat
Letzter Beitrag:
vor 3 Jahren
Beteiligte Autoren:
Tor-Bjarne, Alexandre Leclerc, kimor

Struggling with outlook email

Startbeitrag von Tor-Bjarne am 22.05.2015 11:56


WinDev 19 - 56s

I`m using a EDT_HTML_Text (also tried with EDTY_Rtf_text) to send a formatted email via outlook but I only get a result as shown below:

What is a bit strange is that in the "Sendt element" it shows up right, but the receiver gets what is shown above.

I tried a couple of different code blocks, but I`m a bit confused (to say the least)

With the EDT_HTML_Text I tried (imsg contains a string of html):

Mail[n].sMail.Message= HTMLToText(Imsg)
mail[n].sMail.HTML = ""+imsg+""

With the EDT_Rtf_Text I tried:

Mail[n].sMail.Message= RTFToText(Imsg)
mail[n].sMail.HTML = ""+RTFTOHTML(imsg)+""

But nothing seems to do the trick? :(

Anybode care to point me in the right direction? :)

My array of emails is defined like:

STdocuments is Structure
sFile is string
sEmail is string
sTable is ANSI string
sPrimKey is string
STEmails is Structure
sMail is Email
Attachment is EmailAttach
cEmail is a Class
Doc is array of STdocuments
Mail is array of STEmails
Emailtype is int //1 = html, 2 = RTF


My SendOutlookEmail method is:

nOutlookSessionID is int
// Opens the Outlook session with the default profile
nOutlookSessionID = EmailStartOutlookSession("")
// Session started?
IF nOutlookSessionID = 0 THEN
// Failure starting the session
Error("Failure opening the Outlook session", ErrorInfo())
// // Process
// Info("List of email folders of Outlook:", ...
// EmailListFolder(nOutlookSessionID))
FOR EACH ds OF :Mail

IF EmailSendMessage(nOutlookSessionID, ds.sMail, False) = False THEN
Error("Email: "+ErrorInfo())
// IF EmailSendMessage(SMTP,ds.sMail) = False THEN
// Error("Email: "+ErrorInfo())
// END

// Closes the session

Edit: also the PrepareOneMail method I supply:

PROCEDURE PrepareOneMail(iToMail,ISubject,Imsg,Ifiles)
n is int

n = Add(Mail)

Add(Mail[n].sMail.Recipient, iToMail)

IF INIRead("SMTP","Copy","",gsInifile) "" THEN

IF NoSpace(sFilename) "" THEN
Mail[n].Attachment.Content = fLoadText(sFilename)
Mail[n].Attachment.Name = fExtractPath(sFilename,fFileName+fExtension)
Mail[n].Attachment.ContentType = "application/pdf"
Mail[n].Attachment.ContentDescription = "PDF Invoice"
Add(Mail[n].sMail.Attach, Mail[n].Attachment)
Mail[n].sMail.Sender = INIRead("email","from","",gsInifile)+""
Mail[n].sMail..SenderAddress = INIRead("email","from email","",gsInifile)
Mail[n].smail.DispositionNotification = False
IF :Emailtype = 1 THEN
Mail[n].sMail.Message = RTFToText(Imsg)
// mail[n].sMail.HTML = ""+imsg+""
// EmailImportHTML(Mail[n].sMail,Imsg,"C:\Users\tor_000\Pictures\Images\")
// Mail[n].sMail.Message = HTMLToText(Imsg)
ELSE IF :Emailtype = 2
Mail[n].sMail.Message = RTFToText(Imsg)
Mail[n].sMail.HTML = ""+RTFToHTML(Imsg)+""
Mail[n].sMail.Subject= ISubject



Hi Tor-Bjarne,

The problem might be on the receiver side depending on the configuration of its email software, what software it is. (Does he allow HTML or only text, does it interpret properly the email, etc.)

Do you have access to the email source on the faulty receiver side? Check the email source to see if it is correctly formatted (i.e. you should have, based on your code, a text section and also an HTML section. Is it so?

Did you try to send your email to another email address for test purposes (hotmail, gmail, etc.)? Have you tried another mail client?

On the side of source code, looking very quickly, this looks correct. The ""+imsg+"" is not required.

Very last question: are you sending your emails using SMTP? From the help page it says it is only supported when using POP3 and SMTP. (I'm surprised, but might be so.)

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 22.05.2015 12:23
Hi Tor-Bjarne,

Just another detail about Outlook. Sometimes we have problems with it on customers sites. It looks like in some cases, the users have to set options in their address book to activate or deactivate options like using RTF in email, and funny stuff about attachments. Outlook is he only email client I know that supports RTF. But this causes problems with text and attachments.

We always ask our customers to disable the RTF thing and activate the standard HTML options, then for some of them they also have to go through their address book because in some versions this can be personalize for every single email addresses. So this is a lot of work. In some cases their technician had to also set some configuration options on their Exchange server.

So your problem might just be there if when you experiment is only happening to one or two customer. (Making the tests suggested in the previous message will help you determine where is the problem exactly.)

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 22.05.2015 12:28
Hi Alexandre,

Tank you for your reply

The ""+imsg+"" was actually "HTML-STARTTAG"+imsg+"HTML-ENDTAG" this dissapared from posing (In fact adding html as code eaven in a code section only result in actuall html code gets parsed on this forum :)

For test, I use a installed outlook out of the box and are sending emails to myself (in outlook). That`s why it`s confusing se pictures below:

The same outlook installation Sendt folder:

On the receiver side (same outlook install)

von Tor-Bjarne - am 22.05.2015 13:48

Have you tried to just enter som simple formatted HTML as string to confirm that it works before passing it on from an edit box?
MyMessage..HTML = "Enter your HTML-message"

I would also as Alexandre suggested try to send thru SMTP.


von kimor - am 23.05.2015 19:30
Hi Kimor,

Thank you for your reply :)

In my "Invoice software" there is a option to send email as SMTP and this works great, the drawback with SMTP is that the customers do not know about SMTP Servers, SMTP Ports what internetprovider they are using. If it`s secure requirement and so forth. And for that matter what their Userid/Password is :)

So the easy way is for those with Outlook is to select Outlook as the prefered way to send email,

And since 99% of them want a copy of their sendt invoice in their "sendt folder" in outlook, smtp do not seem to be the right option.

- When they choose the SMTP option they can send a copy of the invoice to them self, but the email is now turning up in the "In box" and not the "Sendt Box". (This sems to be a problem for many of them)

Since 99.99% have outlook (over here in Norway at last) the "Send via Outlook" option seems to be the prefered choice of my users.

I`ve checked the html produced from the EDT_HTML and it`s correct except it`s missing the "HTML" and "HTML_END" tag.


von Tor-Bjarne - am 24.05.2015 11:13
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.