CDO Message attachment rename

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yosi

    CDO Message attachment rename

    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


  • Anthony Jones

    #2
    Re: CDO Message attachment rename

    "Yosi" <yosi1289@gmail .comwrote in message
    news:OCPu5sx8IH A.3928@TK2MSFTN GP04.phx.gbl...
    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 cdoContentDispo sition = "urn:schemas:ma ilheader:conten t-disposition"

    .. . .

    Function AttachFile(roMs g, rsFilePath, rsNewName)

    roMsg.AddAttach ment rsFilePath

    With roMsg.Attachmen ts(1).Fields
    .Item(cdoConten tDisposition) = "attachment;fil ename=" & rsNewName
    .Update
    End With

    End Function

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



    --
    Anthony Jones - MVP ASP/ASP.NET


    Comment

    • Yosi

      #3
      Re: CDO Message attachment rename

      It works !
      Thanks.


      "Anthony Jones" <Ant@yadayadaya da.comwrote in message
      news:eYWwff18IH A.1180@TK2MSFTN GP03.phx.gbl...
      "Yosi" <yosi1289@gmail .comwrote in message
      news:OCPu5sx8IH A.3928@TK2MSFTN GP04.phx.gbl...
      >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 cdoContentDispo sition = "urn:schemas:ma ilheader:conten t-disposition"
      >
      . . .
      >
      Function AttachFile(roMs g, rsFilePath, rsNewName)
      >
      roMsg.AddAttach ment rsFilePath
      >
      With roMsg.Attachmen ts(1).Fields
      .Item(cdoConten tDisposition) = "attachment;fil ename=" & rsNewName
      .Update
      End With
      >
      End Function
      >
      AttachFile(oMsg , "c:\somefolder\ somefile.dat", "pinkelephants. dat")
      >
      >
      >
      --
      Anthony Jones - MVP ASP/ASP.NET
      >
      >

      Comment

      Working...