Need help sending CDO email with dynamic HTML attachment

Discussion in 'ASP General' started by NetNoise, Jan 3, 2005.

  1. NetNoise

    NetNoise Guest

    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
    NetNoise, Jan 3, 2005
    #1
    1. Advertising

  2. NetNoise

    Rob Meade Guest

    "NetNoise" wrote ...

    > 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
    Rob Meade, Jan 3, 2005
    #2
    1. Advertising

  3. NetNoise

    io Guest

    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



    "NetNoise" <> wrote in message
    news:Xns95D3D0622CC4netnoisedesigngroup@130.133.1.4...
    > 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
    io, Jan 4, 2005
    #3
  4. NetNoise

    NetNoise Guest

    "Rob Meade" <> wrote in
    news:jjeCd.2185$:

    > "NetNoise" wrote ...
    >
    >> 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


    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.
    NetNoise, Jan 4, 2005
    #4
  5. NetNoise

    NetNoise Guest

    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


    "io" <> wrote in
    news::

    > 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
    >
    >
    >
    > "NetNoise" <> wrote in message
    > news:Xns95D3D0622CC4netnoisedesigngroup@130.133.1.4...
    >> 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
    NetNoise, Jan 4, 2005
    #5
  6. "NetNoise" <> wrote in message
    news:Xns95D448F349EA3netnoisedesigngroup@130.133.1.4...
    > "Rob Meade" <> wrote in
    > news:jjeCd.2185$:
    >
    > > "NetNoise" wrote ...
    > >
    > >> 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

    >
    > 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
    Chris Hohmann, Jan 4, 2005
    #6
  7. NetNoise

    NetNoise Guest

    "Chris Hohmann" <> wrote in
    news::

    >
    > "NetNoise" <> wrote in message
    > news:Xns95D448F349EA3netnoisedesigngroup@130.133.1.4...
    >> "Rob Meade" <> wrote in
    >> news:jjeCd.2185$:
    >>
    >> > "NetNoise" wrote ...
    >> >
    >> >> 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

    >>
    >> 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_ibodypa
    > rt_addbodypart.asp
    >
    > HTH
    > -Chris Hohmann



    That looks like exactly what I need. Thank you!
    -Geoff
    NetNoise, Jan 10, 2005
    #7
    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. Trapulo
    Replies:
    1
    Views:
    423
    Mike Bridge
    Apr 27, 2005
  2. param
    Replies:
    3
    Views:
    1,598
    mearvk
    Dec 7, 2006
  3. Jay

    CDO not sending email

    Jay, Jan 15, 2004, in forum: ASP General
    Replies:
    5
    Views:
    122
  4. Matthew Margolis

    sending an email with an attachment in ruby

    Matthew Margolis, Aug 7, 2005, in forum: Ruby
    Replies:
    11
    Views:
    245
  5. rabarama
    Replies:
    1
    Views:
    124
    rabarama
    Sep 25, 2009
Loading...

Share This Page