CDO Message attachment rename

Y

Yosi

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
 
A

Anthony Jones

Yosi said:
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")
 
Y

Yosi

It works !
Thanks.


Anthony Jones said:
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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top