Solved

CDONTS Attaching binary files

Posted on 2001-08-21
6
230 Views
Last Modified: 2008-02-01
I am trying to attach a XLS file  to my emails.
When the receiver opens the mails, the attachments is not really valid. Any Suggestions ?

Code:
Dim Mail    
Set Mail = server.createobject("CDONTS.NewMail")

Mail.To = "kim@MrX.com"
Mail.Subject = "Reports from MR X"
Mail.Body = "Attached the 2 reports from MR X"  
Mail.AttachFile "C:\Book1.xls"
Mail.From = "kim@MrX.com"
Mail.Send
set mail = Nothing
0
Comment
Question by:kwk
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:RickHalle
ID: 6412018
I doubt you will find a solution for this.
 http://support.microsoft.com/support/kb/articles/Q262/6/34.ASP

I think most email clients will refuse it because it can present a security risk. You may be able to send it as a plain text file but the receiver will need to change the extension if you do.

Rick Halle
0
 
LVL 2

Expert Comment

by:turbosig
ID: 6412079
It is easy to attach files to mail messages using the AttachFile method of the NewMail object. So if we wanted to attach a bitmap to the mail message we could do so like this:

objMail.AttachFile ("c:\images\logo.bmp", "Our logo")
This would attach the file logo.bmp with the caption "Our logo". By default, the attachment is encoded using the UUENCODE format, but we can override this default and send the attachment using Base 64 format by supplying the optional encodingmethod parameter to the AttachFile method.

objMail.AttachFile ("c:\images\logo.bmp", "Our logo", cdoEncodingBase64)
To set the encoding method for this attachment back to UUENCODE we would use the constant cdoEncodingUUEncode instead. Bear in mind that changing the encoding method for a NewMail object only affects that object. It does not alter the default method used for encoding new NewMail objects.

~Turbo
0
 
LVL 2

Expert Comment

by:RickHalle
ID: 6412093
I need to eat my words. This works for me.
<%
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
     objNewMail.From = "server@mysite.com"
     objNewMail.To = "you@yoursite.com"
     objNewMail.Subject = "Test"
     objNewMail.Body = Now & vbcrlf
     objNewMail.BodyFormat = CdoBodyFormatText
     objNewMail.MailFormat = CdoMailFormatText
     objNewMail.Importance = CdoNormal
     objNewMail.AttachFile "D:\pathtofile\test.xsl"
     objNewMail.Send
     Set objNewMail = Nothing
     Dim objFSO
     Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objFSO = Nothing
%>

Rick Halle
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Accepted Solution

by:
RickHalle earned 100 total points
ID: 6412097
Whoops to much there:
<%
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = "server@mysite.com"
objNewMail.To = "you@yoursite.com"
objNewMail.Subject = "Test"
objNewMail.Body = Now & vbcrlf
objNewMail.BodyFormat = CdoBodyFormatText
objNewMail.MailFormat = CdoMailFormatText
objNewMail.Importance = CdoNormal
objNewMail.AttachFile "D:\pathtofile\test.xsl"
objNewMail.Send
Set objNewMail = Nothing
%>
0
 
LVL 2

Expert Comment

by:turbosig
ID: 6412154
Now your all getting the picture....Remember "Anything" is possible somehow.

~Turbosig --> Happy Coding.
0
 

Author Comment

by:kwk
ID: 6414077
It seems, that the problem i had was in the process of making the XLS file, not in the way I sended the attachment.

The code you posted is just as valid as the original one I posted, i guess.

Thank you for working on this anyway.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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/…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 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

10 Experts available now in Live!

Get 1:1 Help Now