473,748 Members | 6,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7123
"Yosi" <yo******@gmail .comwrote in message
news:OC******** ******@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
Jul 31 '08 #2
It works !
Thanks.
"Anthony Jones" <An*@yadayadaya da.comwrote in message
news:eY******** ******@TK2MSFTN GP03.phx.gbl...
"Yosi" <yo******@gmail .comwrote in message
news:OC******** ******@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


Aug 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1335
by: David | last post by:
I have a C# application that functions as follows: 1. Log onto a pop3 mail account 2. search for any messages from a given source. 3. Get the attachment from the message. (This attachment will ALWAYS be a TIFF file). 4. store new tiff file on local server. I have everything working except the file I save cannot be viewed. I'm sure its because of the formating of the string I store in the
5
2734
by: Tony Meyer | last post by:
On Windows, if I do os.rename(old, new) where old is a file that is in-use (e.g. python itself, or a dll that is loaded), I would expect that an error would be raised (e.g. as when os.remove is called with an in-use file). However, what happens is that a copy of the file is made, and the old file still exists. For example: C:\>c:\python24\python.exe Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32
8
1530
by: Howard | last post by:
Using visual studio 2005 I am sending an email using a vaiable Dim mail As New MailMessage() and then later setting the recipient address by mail.To = name@domain.co.uk This works fine. However the compiler tells me that New MailMessage() is now obsolete and that instead I should use
5
2367
by: Robert Dufour | last post by:
I am trying to use framework 1.1 - stuck with it. to send emails from a windows form application. The email messages can have attachments, usually two and they can be either text or sounds (wav files) or images (bmp, gif or tiff) I can send the email messages OK but the attachments are giving me grief. Can anyone provide some code that adds attachments to web mail messages. Thanks for any help,
6
1973
by: Karl Groves | last post by:
I'm trying to work out a mail system which can send an attachment as well as an HTML formatted message (and a default plain text version). I found some pretty good code on PHP.net and modified it a little but I can't seem to get it to work. It attaches the file properly, but only displays the Plain Text message, even in an HTML-capable mail client. I'm guessing it has something to do with the placement of the boundaries,
11
1867
by: Marc Castrechini | last post by:
The business requirement is relatively simple: Automatically open a new mail message using the default mail client (Outlook 2003) and attach a document located on the server. Obviously we need to open the New Mail Message on the client so we are trying to determine if this is possible by setting the content type and streaming the content to the browser. TIA, - Marc Castrechini
7
13612
by: rn5a | last post by:
When a user posts a HTML Form in an ASP page, the values entered by the user in the Form are mailed to the website owner. Users can also attach a file before posting the Form. To send the e-mail, I am using CDO.MESSAGE. When I tested the app in my local intranet IIS5.1 server, the e-mail part worked fine & even the attachment was sent along with the mail but after deploying the site at godaddy.com, when I try to send a file from my local...
3
3837
by: Steven Allport | last post by:
I am working on processing eml email message using the email module (python 2.5), on files exported from an Outlook PST file, to extract the composite parts of the email. In most instances this works fine, the message is read in using message_from_file, is_multipart returns True and I can process each component and extract message attachments. I am however running into problem with email messages that contain emails forwarded as...
4
6735
by: kpfunf | last post by:
When I email a report via macro or vba code, the attached report is named "Fuel Quote Report.(ext)". I have no idea how this name is used. I have three seperate macros sending three seperate reports. Each macro is named after the report, which are all named differently. The subject messages are different. Yet, in each email, the attachments are all named the same. How does Access name the attachments? I even tried different formats (rtf, snp),...
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.