Solved

New to CDO: Sending client attachments with ASP using CDO

Posted on 2004-08-20
8
360 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 2

Accepted Solution

by:
MGrassman earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 31

Expert Comment

by:alorentz
Comment Utility
>>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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:scene
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now