inline images for emails

Discussion in 'ASP .Net' started by William F. Robertson, Jr., May 23, 2005.

  1. Anyone have any reference for adding a image inline into a email body, using
    the System.Web.MailMessage? If not MailMessage, then anything else would be
    nice.

    ie using the cid and embedding the image with the email

    Thanks,

    bill
    William F. Robertson, Jr., May 23, 2005
    #1
    1. Advertising

  2. not sure that it can be done. I have always use COM interop with CDO.
    Create a "source" web page with your image and point to it. You are creating
    an embeded HTML email.

    -Andrew


    CDO.Message message = new CDO.Message();
    CDO.Configuration configuration = new CDO.Configuration();
    ADODB.Fields fields = configuration.Fields;

    fields[CDO.CdoConfiguration.cdoSendUsingMethod].Value =
    CDO.CdoSendUsing.cdoSendUsingPort;
    fields[CDO.CdoConfiguration.cdoSMTPServer].Value = "127.0.0.1";
    fields[CDO.CdoConfiguration.cdoSMTPServerPort].Value = 25;
    fields[CDO.CdoConfiguration.cdoSMTPConnectionTimeout].Value = 30;
    fields.Update();

    message.Configuration = configuration;

    message.To = textBoxTo.Text;
    message.From = textBoxFrom.Text;
    message.Subject = textBoxSubject.Text;
    message.TextBody = "This is your message body.";

    try
    {
    message.CreateMHTMLBody(textBoxUrl.Text, CDO.CdoMHTMLFlags.cdoSuppressNone,
    textBoxUsername.Text, textBoxPassword.Text);
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    System.Diagnostics.Debug.WriteLine(ex.Message);
    }

    message.Send();


    "William F. Robertson, Jr." <> wrote in message
    news:...
    > Anyone have any reference for adding a image inline into a email body,

    using
    > the System.Web.MailMessage? If not MailMessage, then anything else would

    be
    > nice.
    >
    > ie using the cid and embedding the image with the email
    >
    > Thanks,
    >
    > bill
    >
    >
    Andrew Robinson, May 23, 2005
    #2
    1. Advertising

  3. William F. Robertson, Jr.

    Brock Allen Guest

    HTML email is just like any other HTML page... meaning to show images, you
    need to use a <img> tag with a src attribute that refers to an image that
    can be accessed by the user.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Anyone have any reference for adding a image inline into a email body,
    > using the System.Web.MailMessage? If not MailMessage, then anything
    > else would be nice.
    >
    > ie using the cid and embedding the image with the email
    >
    > Thanks,
    >
    > bill
    >
    Brock Allen, May 23, 2005
    #3
  4. "Html email is just like any other Html page".

    Unless it is being opened in Outlook 2003, and the company build doesn't
    download images automatically. I must place the Base64 encoding of the
    image into the email and reference using the src="cid:image_name" for it to
    work.

    Say hello to Kent for me. I enjoyed chatting with him.

    bill


    "Brock Allen" <> wrote in message
    news:...
    > HTML email is just like any other HTML page... meaning to show images, you
    > need to use a <img> tag with a src attribute that refers to an image that
    > can be accessed by the user.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > Anyone have any reference for adding a image inline into a email body,
    > > using the System.Web.MailMessage? If not MailMessage, then anything
    > > else would be nice.
    > >
    > > ie using the cid and embedding the image with the email
    > >
    > > Thanks,
    > >
    > > bill
    > >

    >
    >
    >
    William F. Robertson, Jr., May 23, 2005
    #4
  5. I guess I could always read the RFC 821 and figure it out. They are
    tightening down the way Outlook processes html messages at work, and need a
    way around forcing the user to click download to view the header image.

    bill

    "Andrew Robinson" <> wrote in message
    news:...
    > not sure that it can be done. I have always use COM interop with CDO.
    > Create a "source" web page with your image and point to it. You are

    creating
    > an embeded HTML email.
    >
    > -Andrew
    >
    >
    > CDO.Message message = new CDO.Message();
    > CDO.Configuration configuration = new CDO.Configuration();
    > ADODB.Fields fields = configuration.Fields;
    >
    > fields[CDO.CdoConfiguration.cdoSendUsingMethod].Value =
    > CDO.CdoSendUsing.cdoSendUsingPort;
    > fields[CDO.CdoConfiguration.cdoSMTPServer].Value = "127.0.0.1";
    > fields[CDO.CdoConfiguration.cdoSMTPServerPort].Value = 25;
    > fields[CDO.CdoConfiguration.cdoSMTPConnectionTimeout].Value = 30;
    > fields.Update();
    >
    > message.Configuration = configuration;
    >
    > message.To = textBoxTo.Text;
    > message.From = textBoxFrom.Text;
    > message.Subject = textBoxSubject.Text;
    > message.TextBody = "This is your message body.";
    >
    > try
    > {
    > message.CreateMHTMLBody(textBoxUrl.Text,

    CDO.CdoMHTMLFlags.cdoSuppressNone,
    > textBoxUsername.Text, textBoxPassword.Text);
    > }
    > catch (Exception ex)
    > {
    > MessageBox.Show(ex.Message);
    > System.Diagnostics.Debug.WriteLine(ex.Message);
    > }
    >
    > message.Send();
    >
    >
    > "William F. Robertson, Jr." <> wrote in message
    > news:...
    > > Anyone have any reference for adding a image inline into a email body,

    > using
    > > the System.Web.MailMessage? If not MailMessage, then anything else

    would
    > be
    > > nice.
    > >
    > > ie using the cid and embedding the image with the email
    > >
    > > Thanks,
    > >
    > > bill
    > >
    > >

    >
    >
    William F. Robertson, Jr., May 23, 2005
    #5
  6. William F. Robertson, Jr.

    Brock Allen Guest

    > Unless it is being opened in Outlook 2003, and the company build
    > doesn't download images automatically.


    Sure, but that's an aspect of the reader, not code that emits and sends the
    HTML email.

    > I must place the Base64
    > encoding of the image into the email and reference using the
    > src="cid:image_name" for it to work.


    That's interesting; I wasn't aware you could do that. So you send a multi-mime
    formatted email with images embedded into it? Well, Outlook refusing to get
    images form the web but automatically loading these embedded images doesn't
    protect me from buffer overflows in their image processing code. I'm still
    vulnerable to attacks then. Shame on outlook :)

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
    Brock Allen, May 23, 2005
    #6
  7. You hope that outlook controls its own buffers. Maybe some of that often
    hyped "code review" at MS took care of this. Not automatically downloading
    images saves spam/email verification and tracking.

    <img src=http://spammer.com/images/header.gif? />

    Now the spammer has a confirmed email address.

    bill

    "Brock Allen" <> wrote in message
    news:...
    > > Unless it is being opened in Outlook 2003, and the company build
    > > doesn't download images automatically.

    >
    > Sure, but that's an aspect of the reader, not code that emits and sends

    the
    > HTML email.
    >
    > > I must place the Base64
    > > encoding of the image into the email and reference using the
    > > src="cid:image_name" for it to work.

    >
    > That's interesting; I wasn't aware you could do that. So you send a

    multi-mime
    > formatted email with images embedded into it? Well, Outlook refusing to

    get
    > images form the web but automatically loading these embedded images

    doesn't
    > protect me from buffer overflows in their image processing code. I'm still
    > vulnerable to attacks then. Shame on outlook :)
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    William F. Robertson, Jr., May 24, 2005
    #7
  8. William F. Robertson, Jr.

    Kevin Guest

    try: www.aspsimply.com/vbnet/NetMailer.aspx
    which does the job and more ...



    "William F. Robertson, Jr." <> wrote in message
    news:...
    > Anyone have any reference for adding a image inline into a email body,
    > using
    > the System.Web.MailMessage? If not MailMessage, then anything else would
    > be
    > nice.
    >
    > ie using the cid and embedding the image with the email
    >
    > Thanks,
    >
    > bill
    >
    >
    Kevin, May 25, 2005
    #8
    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. Abhi
    Replies:
    2
    Views:
    734
    E. Robert Tisdale
    Jul 3, 2003
  2. Alvin
    Replies:
    7
    Views:
    473
    E. Robert Tisdale
    May 6, 2005
  3. Replies:
    3
    Views:
    456
  4. tshad

    Emails from my page losing images

    tshad, Mar 6, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    245
    tshad
    Mar 6, 2007
  5. Augustin Prasanna
    Replies:
    1
    Views:
    1,315
    bruce barker
    Jul 17, 2009
Loading...

Share This Page