Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending HTML EMail with embedded images to Outlook from VFP
Message
De
18/02/2005 16:24:14
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Sending HTML EMail with embedded images to Outlook from VFP
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
00988493
Message ID:
00988493
Vues:
545
I am attempting to create and send an HTML email with embedded images. I am using Redemption to get around the security messages.

The problem is, if I have embedded images in the HTML source, and I display the email before sending it, I can interactively change anything about the body of the email, and the images will be properly embedded in the email. If I DON'T make any changes, then the IMG SRC reference is still as it was in the original HTML source.

Is there any way to force programmatically the email item to refresh and regenerate CID's and embed the images into the email.

***
I received this code suggestion from Redemption, but I am getting an error on the last command. "OLE error code: 0x80002000f: Parameter not optional."

*****
lc_curdir = FULLPATH(CURDIR())
*- Create an instance of Outlook
oOutLook = CreateObject("Outlook.Application")

*-Create an Outlook Mail Item
oItem = oOutLook.CreateItem(0)

*- Create a Redemption Safe Mail Item
sItem = CreateObject("Redemption.SafeMailItem")

CD "&lc_curdir "

*- Wrap Safemailitem around Outlook Mail Item
sItem.Item = oItem

*- Add some HTML to body of email
*- This HTML contains IMG SRC tags, linked to pictures on the hard drive, which need to be embedded in the email.

sItem.HTMLBody = FILETOSTR("v:\data\bookings\new\output\prospect_availability.htm")

*** Normally at this point, I would issue a sItem.Display, but unless I interactively change the body of the email, the recipient will not receive an embedded image, but will instead have a broken link (to the image on our local hard drive)
*** If we change anything interactively, the email refreshes, and pictures are embedded.
*** I need to be able to do this programmatically though, in an instance where I only SEND, (not display) or an instance where the user makes no change to the body of the email.
*** Redemption suggests the following fix, which errors out on the last line (display method)

*- Create a new Outlook Mail Item
NewItem = oOutLook.CreateItem(0)

*- Save a copy of the original email to the New Outlook Mail Item
sItem.CopyTo(NewItem)

*'must save to have EntryID
NewItem.Save
EID = NewItem.EntryID

*'de-reference the old item, then open it again
*'otherwise Outlook might still have tidbits
*'left from the original message
RELEASE NewItem
RELEASE sItem
RELEASE oItem

PUBLIC NewItem, sItem, oItem
*!* Original code suggested, modified per suggestion of Redemption author, below.
*!* *- Retrieve Saved Mail item using Entry ID
*!* NewItem = oOutLook.Session.GetItemFromID(EID)
*!* *- Display the new item
*!* NewItem.Display
*!* Steve,
*!* Try something like the following
*!* …

NewItem = oOutLook.Session.GetItemFromID(EID)
sItem = CreateObject("Redemption.SafeMailItem")
sItem.Item = NewItem
sItem.Display()

&& at this point we have received the error: "OLE error code: 0x80002000f: Parameter not optional."


*****

Any help on this problem would be greatly appreciated.

SDL
Coates & Associates
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform