Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with displaying an image in an automated email 1

Status
Not open for further replies.

Steve-vfp9user

Programmer
Feb 5, 2013
337
GB
Hi

I'm using VFP9 SP2

I have had much success in sending automated emails from VFP9 but have a small issue trying to insert a jpg image as a logo which is stored on our website server.
The code below was used for the exception of the line stored to mbody2 which I have added.

Code:
STORE "Dear "+ALLTRIM(COVERTITLE)+CHR(10)+CHR(10)+ ;
  "Please find attached cover letter and quotation for your attention."+CHR(10)+CHR(10)+ ;
  "We look forward to hearing from you."+CHR(10)+CHR(10)+ ;
  "Regards"+CHR(10)+CHR(10)+CHR(10)+ ;
  PROPER(ALLTRIM(FORENAME))+" "+PROPER(ALLTRIM(SURNAME))+CHR(10) TO mbody1
STORE lcHtmlBody+CHR(10) TO mbody2
STORE "My business, my address, my postcode"+CHR(10)+ ;
  "Web: [URL unfurl="true"]www.mywebsitename.com"+CHR(10)+[/URL] ;
  "Tel: 012 3456 7890 Ext "+ALLTRIM(TELEXT)+" - Fax: 012 3456 7891"+CHR(10) TO mbody3

When I send the email as above, I use the following:

Code:
oOutlook = Createobject('Outlook.Application')
oNameSpace = oOutlook.getnamespace('MAPI')
oOutbox = oNameSpace.GetDefaultFolder(4)
oItems = oOutbox.Items
oMailItem = oItems.Add(0)
oMailItem.To = EMAILADD
oMailItem.Subject = TRIM(msubject)
oMailItem.Body = TRIM(mbody1)+TRIM(mbody2)+TRIM(mbody3)
oMailItem.attachments.add(mcover)
oMailItem.attachments.add(mprop)
oMailItem.ReadReceiptRequested = .T.
oMailItem.Send

Everything still works except the image I am trying to show in the body of the email is shown as:

Code:
<html>[URL unfurl="true"]http://ourwebsite.com/logo/mylogo.jpg</html>[/URL]

I have researched several different options but I keep getting the same result. Here is the line of code I used for the above:

lcHtmlBody = [<html><body>Embedded Image:<br><img src="]

Any ideas please guys?



Thank you

Steve
 
Any HTML starts with <html> tag (besides it should start with a doctype, if you're strict), so you can't mix plaintext and HTML the way you do. You have a html section within plaintext, that won't ever work out, even not with the HTMLBody. So your mbody1 and mbody3 would also need to be HTML, eg <P>...paragraph</P>, and mbody 1 would have the <html> opening tag and mbody3 the closing </html>. Besides that the main visible part of a html text needs to be in the <body>...</body> section within the html tags.

If you're done with that the next hurdle is outlook settings not showing images loaded from a website address.

Bye, Olaf.
 
So basically all the required information for the body of the automated email will need to be encased in HTML

No problem, that makes sense. I'll post back soon

Thank you

Steve
 
I'd suggest composing your mail via TEXT..ENDTEXT with textmerge option:

Code:
TEXT TO lcHTMLBody NOSHOW TEXTMERGE
<!doctype html>
<html>
<body>
<p><img src='[URL unfurl="true"]http://ourwebsite.com/logo/mylogo.jpg'>[/URL] Hamburg, <<DATE()>></p>

<p>Nice weather!</p>

<p>Bye, Olaf.</p>
</body>
</html>
ENDTEXT
oMailItem.HTMLBody =lcHTMLBody

Notice just the image url also doesn't display an image. The <img> tag is for images. If you're unsure about HTML, use an html editor.

Bye, Olaf.
 
Here is the final version that now works for those it may assist in the future:

Code:
HtmlBody = "<HTML><BODY> ;
  <br>Dear "+ALLTRIM(COVERTITLE)+ " ;
  <br><br>Please find attached cover letter and quotation for your attention. ;
  <br><br>We look forward to hearing from you. ;
  <br><br>Regards ;
  <br><br>"+PROPER(ALLTRIM(FORENAME))+" "+PROPER(ALLTRIM(SURNAME))+" ;
  <br><img src='[URL unfurl="true"]http://ourwebsite.com/logo/ourlogo.jpg'>[/URL] ;
  <br>My business, my address, my postcode ;
  <br>Web: mywebsitename.com ;
  <br>Tel: 029 2048 4144 Ext "+ALLTRIM(TELEXT)+" - Fax: 029 2048 3084 ;
  </BODY> ;
  </HTML>"

Part of the code when sending:

Code:
oMailItem.HTMLBody = HtmlBody

I appreciate the posts on this thread.

Thank you

Steve
 
Just want to point out for all that Thor has a tool that highlights everything between parens and goes outward one level at a time. Really handy for stuff like this.

Tamar
 
I'll second Olaf's suggestion to use TEXT/ENDTEXT instead of building one gigantic string the way you're doing it. It's SO much more easy to read and, more important, to maintain when you inevitably have to come back and change the wording of that message. [pipe]
 
Tamar, I think you wanted to post that comment on thread184-1750284

Bye, Olaf.
 
Hi,
@ Tamar:
what is the name of the Thor Tool that "highlights everything between parens and goes outward one level at a time"?
Rgds,
Jockey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top