Need help sending CDO email with dynamic HTML attachment

N

NetNoise

Hi.

I'm using CDO SYS to send email messages. I can attach a file just fine.
However, I need to attach an HTML page that's generated on the fly by my
ASP code. The attachment source code gets assembled into a VB string. How
do I attach this? I think there was an easy way in CDONTS but that's no
longer an option.

Thanks in advance.
-Geoff
 
R

Rob Meade

...
I'm using CDO SYS to send email messages. I can attach a file just fine.
However, I need to attach an HTML page that's generated on the fly by my
ASP code. The attachment source code gets assembled into a VB string. How
do I attach this? I think there was an easy way in CDONTS but that's no
longer an option.

Hi,

Why not write your string out to the server and save the html file, then
attach it.

You'd need to give each file a unique number, and obviously remove them
again to tidy up (assuming now history/audit is required).

Regards

Rob
 
I

io

G'day Geoff,

The following should work:

..........................
..........................
..........................
Dim Mail

Set Mail=Server.CreateObject("CDONTS.NewMail")
Mail.To = <ToAddress>
Mail.From = <FromAddress>
Mail.Subject = <Your Subject>
Mail.BodyFormat = 0 'This indicates HTML
Mail.Body = <Your HTML>
Mail.Send

..........................
..........................
..........................

Cheers
 
N

NetNoise

...


Hi,

Why not write your string out to the server and save the html file,
then attach it.

You'd need to give each file a unique number, and obviously remove
them again to tidy up (assuming now history/audit is required).

Regards

Rob

Thanks Rob. I had thought about that solution. I was hoping not to need
that level of complexity but it may be the only way.
 
N

NetNoise

Thanks for the quick reply... but:
1. CDONTS is not an option (they upgraded to Win2003 Server), and
2. I need the HTML to show up as a file attachment

I'm using the CDO-SYS equivalient of your suggestion right now and it
works just fine.

Cheers.
-Geoff
 
C

Chris Hohmann

NetNoise said:
Thanks Rob. I had thought about that solution. I was hoping not to need
that level of complexity but it may be the only way.

You can avoid the need to create a temporary file by writing directly to the
IStream interface that is implemented by the IBodyPart interface. Here's the
documentation for the AddBodyPart Method of the IBodyPart interface which
has an example of what you're attempting to do:
http://www.msdn.microsoft.com/library/en-us/cdosys/html/_cdosys_ibodypart_addbodypart.asp

HTH
-Chris Hohmann
 

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

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top