Solved

CDONTS Attaching binary files

Posted on 2001-08-21
6
229 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

IT, Stop Being Called Into Every Meeting

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!

Join & Write a Comment

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

25 Experts available now in Live!

Get 1:1 Help Now