CDO Message attachment rename

Discussion in 'ASP General' started by Yosi, Jul 31, 2008.

  1. Yosi

    Yosi Guest

    Hi All

    I have recently changed my send email vbscript to work on W2K3 and I am now
    using the CDO.Message object. I need to rename files attached to the email
    without copying / renaming the file itself. With the old CDONTS.NewMail
    object I used in w2k, this was achieved with AttachFile (FilePath,
    NewFileName).

    There doesn't appear to be a similar function with CDO so I was wandering if
    anyone had found a function or a way of doing it.

    Many thanx in advance
    Yosi
    Yosi, Jul 31, 2008
    #1
    1. Advertising

  2. "Yosi" <> wrote in message
    news:...
    > Hi All
    >
    > I have recently changed my send email vbscript to work on W2K3 and I am

    now
    > using the CDO.Message object. I need to rename files attached to the email
    > without copying / renaming the file itself. With the old CDONTS.NewMail
    > object I used in w2k, this was achieved with AttachFile (FilePath,
    > NewFileName).
    >
    > There doesn't appear to be a similar function with CDO so I was wandering

    if
    > anyone had found a function or a way of doing it.
    >



    Its a bit messy in CDOSYS you need to rewrite the Content-Disposition header
    yourself:-


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

    .. . .

    Function AttachFile(roMsg, rsFilePath, rsNewName)

    roMsg.AddAttachment rsFilePath

    With roMsg.Attachments(1).Fields
    .Item(cdoContentDisposition) = "attachment;filename=" & rsNewName
    .Update
    End With

    End Function

    AttachFile(oMsg, "c:\somefolder\somefile.dat", "pinkelephants.dat")



    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Jul 31, 2008
    #2
    1. Advertising

  3. Yosi

    Yosi Guest

    It works !
    Thanks.


    "Anthony Jones" <> wrote in message
    news:...
    > "Yosi" <> wrote in message
    > news:...
    >> Hi All
    >>
    >> I have recently changed my send email vbscript to work on W2K3 and I am

    > now
    >> using the CDO.Message object. I need to rename files attached to the
    >> email
    >> without copying / renaming the file itself. With the old CDONTS.NewMail
    >> object I used in w2k, this was achieved with AttachFile (FilePath,
    >> NewFileName).
    >>
    >> There doesn't appear to be a similar function with CDO so I was wandering

    > if
    >> anyone had found a function or a way of doing it.
    >>

    >
    >
    > Its a bit messy in CDOSYS you need to rewrite the Content-Disposition
    > header
    > yourself:-
    >
    >
    > Const cdoContentDisposition = "urn:schemas:mailheader:content-disposition"
    >
    > . . .
    >
    > Function AttachFile(roMsg, rsFilePath, rsNewName)
    >
    > roMsg.AddAttachment rsFilePath
    >
    > With roMsg.Attachments(1).Fields
    > .Item(cdoContentDisposition) = "attachment;filename=" & rsNewName
    > .Update
    > End With
    >
    > End Function
    >
    > AttachFile(oMsg, "c:\somefolder\somefile.dat", "pinkelephants.dat")
    >
    >
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET
    >
    >
    Yosi, Aug 2, 2008
    #3
    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. rabbits77
    Replies:
    0
    Views:
    854
    rabbits77
    Feb 26, 2004
  2. NetNoise
    Replies:
    6
    Views:
    357
    NetNoise
    Jan 10, 2005
  3. CDO.MESSAGE ATTACHMENT

    , May 19, 2007, in forum: ASP General
    Replies:
    4
    Views:
    578
    Dave Anderson
    May 21, 2007
  4. RN1

    Attachment Using CDO.MESSAGE

    RN1, Dec 14, 2007, in forum: ASP General
    Replies:
    9
    Views:
    627
  5. SSG
    Replies:
    0
    Views:
    147
Loading...

Share This Page