inline images for emails

  • Thread starter Thread starter William F. Robertson, Jr.
  • Start date Start date
W

William F. Robertson, Jr.

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
 
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();
 
"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
 
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 said:
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 said:
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
 
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
 
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/[email protected] />

Now the spammer has a confirmed email address.

bill
 
Back
Top