469,903 Members | 1,463 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

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
Jul 31 '08 #1
2 6625
"Yosi" <yo******@gmail.comwrote in message
news:OC**************@TK2MSFTNGP04.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 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
Jul 31 '08 #2
It works !
Thanks.
"Anthony Jones" <An*@yadayadayada.comwrote in message
news:eY**************@TK2MSFTNGP03.phx.gbl...
"Yosi" <yo******@gmail.comwrote in message
news:OC**************@TK2MSFTNGP04.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 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


Aug 2 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Karl Groves | last post: by
11 posts views Thread by Marc Castrechini | last post: by
7 posts views Thread by rn5a | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.