Create an email attachment using a stream in classic ASP (not ASP.Net)

Discussion in 'ASP General' started by brendan_gallagher_2001@yahoo.co.uk, Nov 8, 2006.

  1. Guest

    Hi,

    Does anyone know how to create an attachment using a stream in classic
    ASP.

    I can see that it can be done in ASP.Net as per the article below:
    Initializes a new instance of the Attachment class with the specified
    stream and name.
    http://msdn2.microsoft.com/en-us/library/6sdktyws.aspx.

    Any help is greatly appreciated.

    regards
    Brendan
    , Nov 8, 2006
    #1
    1. Advertising

  2. Slim Guest

    Slim, Nov 8, 2006
    #2
    1. Advertising

  3. Guest

    Thanks. I should have also mentioned in my original query that I want
    to avoid creating a file on any directory. I just want to set the
    content of the attachement to the content of a stream.

    Slim wrote:
    > http://support.microsoft.com/default.aspx/kb/286430
    >
    >
    >
    > <> wrote in message
    > news:...
    > > Hi,
    > >
    > > Does anyone know how to create an attachment using a stream in classic
    > > ASP.
    > >
    > > I can see that it can be done in ASP.Net as per the article below:
    > > Initializes a new instance of the Attachment class with the specified
    > > stream and name.
    > > http://msdn2.microsoft.com/en-us/library/6sdktyws.aspx.
    > >
    > > Any help is greatly appreciated.
    > >
    > > regards
    > > Brendan
    > >
    , Nov 8, 2006
    #3
  4. <> wrote in message
    news:...
    > Hi,
    >
    > Does anyone know how to create an attachment using a stream in classic
    > ASP.
    >
    > I can see that it can be done in ASP.Net as per the article below:
    > Initializes a new instance of the Attachment class with the specified
    > stream and name.
    > http://msdn2.microsoft.com/en-us/library/6sdktyws.aspx.
    >
    > Any help is greatly appreciated.
    >
    > regards
    > Brendan
    >


    Heres an example:-

    Const cdoContentDispostion = "urn:schemas:mailheader:content-disposition"
    Const cdoBase64 = "base64"

    Set oPart = oMsg.Attachments.Add

    oPart.ContentMediaType = "application/octet-stream"
    oPart.ContentTransferEncoding = cdoBase64

    oPart.Fields(cdoContentDisposition).Value = "attachment;
    filename=""Test.dat"""
    oPart.Fields.Update

    Set oStreamOut = oPart.GetDecodedContentStream
    oStreamOut.Write aByt
    oStreamOut.Flush


    Where oMsg is an existing cdoMessage (ensure you've added any text and/or
    html bodies first) and abyt is the set of bytes that represents the resource
    to attach.

    What type of content are you attaching?
    Anthony Jones, Nov 8, 2006
    #4
  5. Guest

    Hi Anthony,

    Thanks for the example. I'll test shortly. I am attaching plain text.

    Brendan

    Anthony Jones wrote:
    > <> wrote in message
    > news:...
    > > Hi,
    > >
    > > Does anyone know how to create an attachment using a stream in classic
    > > ASP.
    > >
    > > I can see that it can be done in ASP.Net as per the article below:
    > > Initializes a new instance of the Attachment class with the specified
    > > stream and name.
    > > http://msdn2.microsoft.com/en-us/library/6sdktyws.aspx.
    > >
    > > Any help is greatly appreciated.
    > >
    > > regards
    > > Brendan
    > >

    >
    > Heres an example:-
    >
    > Const cdoContentDispostion = "urn:schemas:mailheader:content-disposition"
    > Const cdoBase64 = "base64"
    >
    > Set oPart = oMsg.Attachments.Add
    >
    > oPart.ContentMediaType = "application/octet-stream"
    > oPart.ContentTransferEncoding = cdoBase64
    >
    > oPart.Fields(cdoContentDisposition).Value = "attachment;
    > filename=""Test.dat"""
    > oPart.Fields.Update
    >
    > Set oStreamOut = oPart.GetDecodedContentStream
    > oStreamOut.Write aByt
    > oStreamOut.Flush
    >
    >
    > Where oMsg is an existing cdoMessage (ensure you've added any text and/or
    > html bodies first) and abyt is the set of bytes that represents the resource
    > to attach.
    >
    > What type of content are you attaching?
    , Nov 8, 2006
    #5
  6. <> wrote in message
    news:...
    > Hi Anthony,
    >
    > Thanks for the example. I'll test shortly. I am attaching plain text.
    >


    In that case I'll adjust the example:-

    Const cdoContentDisposition = "urn:schemas:mailheader:content-disposition"

    Dim oPart : Set oPart = oMsg.Attachments.Add

    oPart.ContentMediaType = "text/plain; charset=iso-8859-1"
    oPart.CharSet = "iso-8859-1"
    oPart.ContentTransferEncoding = "quoted-printable"

    oPart.Fields(cdoContentDisposition).Value =
    "attachment;filename=""Test.txt"""
    oPart.Fields.Update

    Dim oStreamOut: Set oStreamOut = oPart.GetDecodedContentStream
    oStreamOut.WriteText sContent
    oStreamOut.Flush

    Where sContent is the string content you want to include in the email


    > Brendan
    >
    > Anthony Jones wrote:
    > > <> wrote in message
    > > news:...
    > > > Hi,
    > > >
    > > > Does anyone know how to create an attachment using a stream in classic
    > > > ASP.
    > > >
    > > > I can see that it can be done in ASP.Net as per the article below:
    > > > Initializes a new instance of the Attachment class with the specified
    > > > stream and name.
    > > > http://msdn2.microsoft.com/en-us/library/6sdktyws.aspx.
    > > >
    > > > Any help is greatly appreciated.
    > > >
    > > > regards
    > > > Brendan
    > > >

    > >
    > > Heres an example:-
    > >
    > > Const cdoContentDispostion =

    "urn:schemas:mailheader:content-disposition"
    > > Const cdoBase64 = "base64"
    > >
    > > Set oPart = oMsg.Attachments.Add
    > >
    > > oPart.ContentMediaType = "application/octet-stream"
    > > oPart.ContentTransferEncoding = cdoBase64
    > >
    > > oPart.Fields(cdoContentDisposition).Value = "attachment;
    > > filename=""Test.dat"""
    > > oPart.Fields.Update
    > >
    > > Set oStreamOut = oPart.GetDecodedContentStream
    > > oStreamOut.Write aByt
    > > oStreamOut.Flush
    > >
    > >
    > > Where oMsg is an existing cdoMessage (ensure you've added any text

    and/or
    > > html bodies first) and abyt is the set of bytes that represents the

    resource
    > > to attach.
    > >
    > > What type of content are you attaching?

    >
    Anthony Jones, Nov 8, 2006
    #6
  7. Guest

    Thanks Anthony. Your code works perfectly.
    Brendan
    Anthony Jones wrote:
    > <> wrote in message
    > news:...
    > > Hi Anthony,
    > >
    > > Thanks for the example. I'll test shortly. I am attaching plain text.
    > >

    >
    > In that case I'll adjust the example:-
    >
    > Const cdoContentDisposition = "urn:schemas:mailheader:content-disposition"
    >
    > Dim oPart : Set oPart = oMsg.Attachments.Add
    >
    > oPart.ContentMediaType = "text/plain; charset=iso-8859-1"
    > oPart.CharSet = "iso-8859-1"
    > oPart.ContentTransferEncoding = "quoted-printable"
    >
    > oPart.Fields(cdoContentDisposition).Value =
    > "attachment;filename=""Test.txt"""
    > oPart.Fields.Update
    >
    > Dim oStreamOut: Set oStreamOut = oPart.GetDecodedContentStream
    > oStreamOut.WriteText sContent
    > oStreamOut.Flush
    >
    > Where sContent is the string content you want to include in the email
    >
    >
    > > Brendan
    > >
    > > Anthony Jones wrote:
    > > > <> wrote in message
    > > > news:...
    > > > > Hi,
    > > > >
    > > > > Does anyone know how to create an attachment using a stream in classic
    > > > > ASP.
    > > > >
    > > > > I can see that it can be done in ASP.Net as per the article below:
    > > > > Initializes a new instance of the Attachment class with the specified
    > > > > stream and name.
    > > > > http://msdn2.microsoft.com/en-us/library/6sdktyws.aspx.
    > > > >
    > > > > Any help is greatly appreciated.
    > > > >
    > > > > regards
    > > > > Brendan
    > > > >
    > > >
    > > > Heres an example:-
    > > >
    > > > Const cdoContentDispostion =

    > "urn:schemas:mailheader:content-disposition"
    > > > Const cdoBase64 = "base64"
    > > >
    > > > Set oPart = oMsg.Attachments.Add
    > > >
    > > > oPart.ContentMediaType = "application/octet-stream"
    > > > oPart.ContentTransferEncoding = cdoBase64
    > > >
    > > > oPart.Fields(cdoContentDisposition).Value = "attachment;
    > > > filename=""Test.dat"""
    > > > oPart.Fields.Update
    > > >
    > > > Set oStreamOut = oPart.GetDecodedContentStream
    > > > oStreamOut.Write aByt
    > > > oStreamOut.Flush
    > > >
    > > >
    > > > Where oMsg is an existing cdoMessage (ensure you've added any text

    > and/or
    > > > html bodies first) and abyt is the set of bytes that represents the

    > resource
    > > > to attach.
    > > >
    > > > What type of content are you attaching?

    > >
    , Nov 13, 2006
    #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. param
    Replies:
    3
    Views:
    1,601
    mearvk
    Dec 7, 2006
  2. James
    Replies:
    1
    Views:
    250
    Paul Lalli
    Aug 4, 2004
  3. Replies:
    0
    Views:
    226
  4. ecureuil
    Replies:
    0
    Views:
    322
    ecureuil
    May 28, 2006
  5. Ted Byers
    Replies:
    0
    Views:
    251
    Ted Byers
    Mar 20, 2009
Loading...

Share This Page