Solved

CDONTS Attaching binary files

Posted on 2001-08-21
6
232 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Classic ASP application Will support SQL 2014 5 94
One field not displaying content (ASP Classic) 8 31
Select case on click 3 21
Weighted Randomizing 6 30
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 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