Embedding images and dynamic content in an email, programmatically

Discussion in 'ASP General' started by Chris Nafziger, Oct 11, 2004.

  1. In my code to send email from VBScript, I use standard CDOSYS code similar to
    the following:

    With oMsg
    Set .Configuration = oCon
    .To = """Admin"" <>"
    .From = """Joe Admin"" <>"
    .Subject = "Hey You!"
    .TextBody = "Service(s) have failed!"
    .Send
    End With

    I understand the use of the .HTMLBody property, as well as the
    ..CreateMHTMLBody method. So I know I can create an ASP or HTML page, and
    pass it to the .CreateMHTMLBody method, to get the images truly embedded, so
    the email source contains the cid:blahblahblah references to the images,
    which is key to getting the email to display properly in web-based mail
    clients.

    My question is... how do I achieve the same thing (embed the images) that
    the .CreateMHTMLBody method does automatically, manually, so I can also
    inject values passed from a form postback into the email?

    It seems that I shouldn't use the .CreateMHTMLBody method. It seems that I
    need to manually accomplish what it accomplishes automatically, so I have
    more granular control. But I have found no thorough online resources that
    explain exactly how. I have thoroughly looked at all of the SDK information
    pertaining to CDOSYS, and I am still in dire need of an example for
    VBScript...

    It seems that the .AddRelatedBodyPart method is part of the answer, but when
    I use it to embed the images and fill .HTMLBody, rather than using the
    ..CreateMHTMLBody method, I do not see cid:blahblahblah in the email source,
    and the images do not display properly in web-based mail clients such as
    Outlook Web Access.

    I really need some help on this. It would also appear that I am not alone.
    I find plenty of questions on this, but no answers. Can anyone help with a
    working VBScript example that embeds images into an email in a fashion that
    yields the cid:blahblahblah in the email source, for the image references,
    that does not use the .CreateMHTMLBody method to do the work automatically?
    Chris Nafziger, Oct 11, 2004
    #1
    1. Advertising

  2. Chris Nafziger

    Alex Deveza Guest

    The answer is to use .addRelatedBodyParts, the example that they provide is
    missing something, the place where "..src=""xyz.gif"" is mentioned, you
    should modify the HTML to say "...src=""cid:xyz.gif"", and reference
    "xyz.gif" when you call addRelatedBodyParts. I was working on these for days,
    and by just mere luck, I stumble onto it...hope this helps.

    Alex

    "Chris Nafziger" wrote:

    > In my code to send email from VBScript, I use standard CDOSYS code similar to
    > the following:
    >
    > With oMsg
    > Set .Configuration = oCon
    > .To = """Admin"" <>"
    > .From = """Joe Admin"" <>"
    > .Subject = "Hey You!"
    > .TextBody = "Service(s) have failed!"
    > .Send
    > End With
    >
    > I understand the use of the .HTMLBody property, as well as the
    > .CreateMHTMLBody method. So I know I can create an ASP or HTML page, and
    > pass it to the .CreateMHTMLBody method, to get the images truly embedded, so
    > the email source contains the cid:blahblahblah references to the images,
    > which is key to getting the email to display properly in web-based mail
    > clients.
    >
    > My question is... how do I achieve the same thing (embed the images) that
    > the .CreateMHTMLBody method does automatically, manually, so I can also
    > inject values passed from a form postback into the email?
    >
    > It seems that I shouldn't use the .CreateMHTMLBody method. It seems that I
    > need to manually accomplish what it accomplishes automatically, so I have
    > more granular control. But I have found no thorough online resources that
    > explain exactly how. I have thoroughly looked at all of the SDK information
    > pertaining to CDOSYS, and I am still in dire need of an example for
    > VBScript...
    >
    > It seems that the .AddRelatedBodyPart method is part of the answer, but when
    > I use it to embed the images and fill .HTMLBody, rather than using the
    > .CreateMHTMLBody method, I do not see cid:blahblahblah in the email source,
    > and the images do not display properly in web-based mail clients such as
    > Outlook Web Access.
    >
    > I really need some help on this. It would also appear that I am not alone.
    > I find plenty of questions on this, but no answers. Can anyone help with a
    > working VBScript example that embeds images into an email in a fashion that
    > yields the cid:blahblahblah in the email source, for the image references,
    > that does not use the .CreateMHTMLBody method to do the work automatically?
    >
    >
    >
    Alex Deveza, Oct 17, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    878
    Eliyahu Goldin
    Jan 4, 2005
  2. hazz
    Replies:
    6
    Views:
    49,400
    SkyUCHC
    Jun 9, 2010
  3. Kurt
    Replies:
    0
    Views:
    179
  4. NickH
    Replies:
    9
    Views:
    161
    Randy Webb
    Jan 22, 2004
  5. ashish makani
    Replies:
    5
    Views:
    556
    Mark Lawrence
    Sep 20, 2012
Loading...

Share This Page