inline images for emails

  • Thread starter William F. Robertson, Jr.
  • 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
 
A

Andrew Robinson

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();
 
B

Brock Allen

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.
 
W

William F. Robertson, Jr.

"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
 
W

William F. Robertson, Jr.

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
 
B

Brock Allen

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 :)
 
W

William F. Robertson, Jr.

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top