Solved

CDONTS Attaching binary files

Posted on 2001-08-21
6
234 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
[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
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
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 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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