Click here to Skip to main content
Click here to Skip to main content

Attaching files with a CDO mail

By , 22 Jun 2004
 

Introduction

Hello guys, here is the code for who search for a CDO mailing attachment. In this case, I have used the file attachment based on the number of selected items in the Request page. If the relevant check is done for the file download, then the related files will be added in the attachment and sent as mail.

'++++++++++= CDO Mail ++++++++++++++++

set objMessage = createobject("cdo.message")
set objConfig = createobject("cdo.configuration")

' Setting the SMTP Server
Set Flds = objConfig.Fields
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 
  "smtpserver"
Flds.update


Set objMessage.Configuration = objConfig
objMessage.To = strRecipientString
objMessage.From = strFromString
objMessage.Subject = strSubject
objMessage.TextBody = strMessageBody

'--------- Attach the files -----------

For i=1 to counter
FreeTools = Request.Form("dowloadfile")(i)
objMessage.AddAttachment(Server.MapPath(download))

Next

objMessage.fields.update
objMessage.Send


set objMessage = nothing
set objConfig = nothing

Hope you guys can program with it.

Happy programming!!!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

rampdci
India India
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHow do you attach files that the user submits through a form?memberdeprivedwriter26 Sep '08 - 6:19 
Like the subject line says, how do you attach files that the user submits through a form?
 
Say for instance I have this website where customers want to attach an advertising image to their invoice and their invoice gets sent to me. How do I attach that file to the email? I use a very similar e-mail system as the one you have here.
 
Thanks
GeneralAttaching a PDF On-the-flymemberTWZDegen31 Oct '06 - 10:35 
Anyone know how this code can be modified to attached a pdf file created on the fly from the browser?
GeneralRe: Attaching a PDF On-the-flymemberRothariger7 Feb '07 - 9:58 
hello, i think you must first, upload the file to the mail server, and then, send it...
 
i gguess there is no other way... unless you create a senmail in the client with javascript...
 

QuestionAn error occurs evrytimememberlive n let live28 Apr '06 - 0:03 
Hi,
 
The code is perfect. i've also used this code for sending a mail. But there is alittle problem with this attachment.
 
an error "the file can't be found in the specific location". eventhough the attached file is there. How come?
 
is there something to be done with the server properties to a user can attach a file?
 
Please help me understand this thing.
 
thank you

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 23 Jun 2004
Article Copyright 2004 by rampdci
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid