[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

New to CDO: Sending client attachments with ASP using CDO

Posted on 2004-08-20
8
Medium Priority
?
384 Views
Last Modified: 2008-02-01
Hi,

We are a small office with a network running a Cobalt Qube 3 server (LINUX).
This box has Chilisoft ASP, and a couple of components: Chil!Mail, Chili!Upload.
My .asp apps work great now. Using CDONTS.

We are now in the process of upgrading our complete network. My apps will need to move over to our new server: Windows 2003 Standard O/S.
I have read many posts, and know that I have to save the file to the server before attaching to the email.

I am therefore new to CDO.
If I have a standard HTML form with an Input box for the client to select a file, how do I save this to our server and then attach to my email. ?


I have the following code which works for sending the email....I just need to add code to SAVE to file and then ATTACH


+++++++++++++++++


<html>
<body>

<%

response.write "Email sent....Check your in-box !"

strTo = "ME@ME.COM"
strFrom = "YOU@YOU.COM"
strSubject = "TEST EMAIL"
strBody = "The content of email"
strIP = "XX.XX.XX.XX" ' Put your ip here

Set objCDOMail = Server.CreateObject("CDO.Message")
   
' Set the properties of the object
 objCDOMail.From = StrFrom
 objCDOMail.To = strTo
 objCDOMail.Subject = strSubject
 objCDOMail.TextBody = strBody
 objCDOMail.Configuration.Fields("cdo/configuration/smtpserver") = strIP
 objCDOMail.Configuration.Fields("cdo/configuration/sendusing") = 2
 objCDOMail.Configuration.Fields.Update


' Some of the more useful ones I've included samples of here:
' objCDOMail.Cc = "mailto:thirt@cinci.rr.com;ahirt@cinci.rr.com"
' objCDOMail.Bcc = "Khirt@cinci.rr.com"
' objCDOMail.Importance = 1
' objCDOMail.AttachFile "d:\websites\als\about.html", "filename.txt"

' Send the message!
objCDOMail.Send

' Set the object to nothing because it immediately becomes
' invalid after calling the Send method + it clears it out of the Server's Memory.
Set objCDOMail = Nothing

   

%>

</body>
</html>

+++++++++++++++++

Appreciate your soonest help

David
0
Comment
Question by:scene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 2

Accepted Solution

by:
MGrassman earned 250 total points
ID: 11851041
I don't know if this is what you are looking for but this is how you save a file in asp.

You will also need write permissions of the folder so I usually use a temp folder

set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile(server.MapPath("temp/name_of_file_to_save.txt"), True) 'True means to overwrite
filetxt.WriteLine("First line of text")
filetxt.Write("No line break after command")
filetxt.WriteLine("Last Line of text")
filetxt.Close

Hope this helps
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11851110
Use chiliupload to upload the file, and then use CDO to send the mail with the attachment.  You seem to know how to do that?  What is your question?
0
 

Author Comment

by:scene
ID: 11851124
Thanks,

The files are usually MS Word docs..does this matter using CreateTextFile ?

Also, for some reason, my code does not like the METHOD 'objCDOMail.AttachFile'

Object doesn't support this property or method: 'AttachFile'
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:alorentz
ID: 11851157
>>does this matter using CreateTextFile ?

Yes, FSO does not create.doc files...that is why you need to use an upload component.

See here for syntax:

http://www.paulsadowski.com/WSH/cdo.htm
0
 

Author Comment

by:scene
ID: 11851164
alorentz,

Sorry, should have been clearer.

Lets forget about CDONTS & Chili!Upload.
Just think Windows 2003 Server & CDO.

HTML Page, using form upload.
Filename carried to asp page.

How do I save their selected doc to file, and then how can I test if it exists and if so, attach it to my email ?

Thanks again

David
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11851222
Again, you need SOME KIND OF UPLOAD COMPONENT.  Unless you want to write it all yourself, buy why do that when you can get a free component.

Try ASPSIMPLEUPLOAD http://www.aquanet.co.il/vip/download/dialers, or ASPUPLOAD.

And, I gave you code for CDO.
0
 
LVL 2

Expert Comment

by:MGrassman
ID: 11851770
No that won't I thought you were creating the file

With the chiliUpload object you created use this

objChili.SaveToFile("/upload/" & filename)

you may need the full server path to the upload folder \root\mysite\uploadfolder

The folder has to be created and given write permissions.


0
 
LVL 11

Expert Comment

by:mouatts
ID: 11853936
As alorentz has said using a component is probably the easiest way but you can do it in plain ASP if you want by using ADO.Stream to read the file from request.binaryread and then save it. If you want the actual code let me know.

Steve
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question