Embed image when using postie.

Started by troncy, March 22, 2014, 05:33:12 AM

Previous topic - Next topic

troncy

Bonjour,

I am trying to send a html mail with an embedded image... without success.
I only get the attachement, but the image in the html body is broken.

Here is the last part of my code

pic = "C:\temp\temp\20130118.gif"
HTMLBody = StrCat("<html><head><title></title></head><body><p>This is a picture.</p> <img src='cid:",FileRoot( pic ),".",FileExtension( pic ),"' height=211 width=1000></body></html>")
attachments=pic

kInit(host,fromaddr,userid,password,port)
kDest(tolist,cclist,bcclist)
ret = kSendText(subject,HTMLBody,attachments,flags)


Any idea of what is wrong ?
merci
Regards
Claude

JTaylor

You are sending the image as an attachment but you then address the image in the HTML assuming it will somehow be found but that will not be the case.   You need to put the image in a location that is accessible by whoever is reading it, just like it would be in a web page.    If you have a webserver put the image(s) there and address them accordingly and it should work.

Jim

troncy

Hello,
Thank you for your answer.
But if you look at the following link :
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/Postie+Email~with~Embedded~Graphic.txt
it seems possible to embedded the graphic into the mail.

Regards
Claude


JTaylor

Maybe I'm wrong.   I know some email clients will display images that are attachments but not sure how it would find the image as part of the HTML call???   Hopefully someone who knows more than me, which is most, will chime in.

Jim

troncy

Thank you Jim,

Looking into the mail code source, i can see the image in the Content-Transfert-Encoding and the Content-Type is also correct with the name I use in the cid tag.

Another thing.... Using the same HTML body with the Thunderbird command line (Which is not very convenient) it works. That let me think I do something wrong with postie.

Regards
Claude

 

....IFICantBYTE

Referencing the attached picture via cid: works fine in Outlook, BUT you have to send the email the right way with Postie...

You have to set the flags to "h" for HTML

flags = "h"

I just tested it and it works with "h" as the flag parameter ... (tested via Exchange / Outlook)
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

JTaylor

I missed the cid part....was just seeing the img HTML code.  Sorry for trying to mislead you.

Jim

troncy

@IFICantBYTE

Bonjour,

Yes I have the flags parameter set to "h" when using postie.
What do you mean by tested via (exchange / outlook) with "h" as flag parameter.

host is set, for me, as my provider smtp server, in the kInit function.

Best regards

Claude

....IFICantBYTE

Hello Claude,
what I meant was that I have tested it at work, internally on the LAN within the company I work for...

Using Postie and a slightly modified version of the script you posted here, I sent an email (on port 25) to our Exchange server's public SMTP gateway..  it was received and the script exited.
The email then finds its way within our various Exchange servers to my mailbox.
My PC, logged in and running Outlook, can then see the email, open it, and hey-presto.... the email's body is the HTML with the picture showing.

It should be pretty much the same result no matter if I was outside our organisation and sending it in, or if I was using or sending to a different email system I would think... if your tests using something other than Postie worked, then Postie should work too.


Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

troncy

Hello IFICantBYTE,

Thank you for your answer... I understand now. So why do I have a problem ?

First of all, I am using Postie in a 2010 version... That may be the problem ! ...I cannot buy a exchange server... :D May be winbatch can tell me.
When I look in my message code on the receiver side, I do not see any Content-ID generated, that could be the problem. I thought it was the Postie job to create it.

I first try to bypass the problem using CDO to send the mail. The problem was the same, no Content-ID at all.
After that I decide to add a body part with the following code
objp = objMessage.AddRelatedBodyPart("C:\temp\temp\20130118.gif", "20130118.gif", 1)
objp.Fields.Item("urn:schemas:mailheader:Content-ID").Value = "<20130118.gif>"


And it is working now, I get the picture showing.

So... Why is it not working with postie, as in this example ?
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/Postie+Email~with~Embedded~Graphic.txt

Did you change something to generate the Content-ID

Again thank you very much for your help.

Best regards.
Claude

Deana

Difficult to say what could be going on. I tested the code sample in the tech database and it successfully sent an HTML email with an imbedded image. See if you can use that code sample but only modify the image and email account information.

When you receive the email in your email client. Try saving out the email message to disk then view its contents using the Binary File Browser included with WinBatch.
Deana F.
Technical Support
Wilson WindowWare Inc.

td

Quote from: troncy on March 24, 2014, 07:19:43 AM
Hello IFICantBYTE,

Thank you for your answer... I understand now. So why do I have a problem ?

First of all, I am using Postie in a 2010 version... That may be the problem ! ...I cannot buy a exchange server... :D May be winbatch can tell me.
When I look in my message code on the receiver side, I do not see any Content-ID generated, that could be the problem. I thought it was the Postie job to create it.

I first try to bypass the problem using CDO to send the mail. The problem was the same, no Content-ID at all.
After that I decide to add a body part with the following code
objp = objMessage.AddRelatedBodyPart("C:\temp\temp\20130118.gif", "20130118.gif", 1)
objp.Fields.Item("urn:schemas:mailheader:Content-ID").Value = "<20130118.gif>"


And it is working now, I get the picture showing.

So... Why is it not working with postie, as in this example ?
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/Postie+Email~with~Embedded~Graphic.txt

Did you change something to generate the Content-ID

Again thank you very much for your help.

Best regards.
Claude

I think you have done well diagnosing the problem.  Postie is not adding the Content-ID as one might expect.   Apparently, this is not a problem for some email clients but likely is a problem for email clients that strictly adhere to the standards, like Thunderbird.   

I am not aware of a way to force Postie to generate a 'Content-ID', although that doesn't mean one doesn't exist.  WinBatch does provide several methods to send email other than Postie so your best bet may be to use one of those other techniques.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

troncy

Hello,

Thank you everybody for your help.
So I will stay with the CDO method as Postie cannot today generate the Content-ID.
For information the problem exist not only with Thunderbird, but also with gmail and hotmail....

Best regards
Claude