all groups > iis smtp nntp > september 2005 >
You're in the

iis smtp nntp

group:

CDONTS Attachfile error


CDONTS Attachfile error lankylad
9/16/2005 7:47:04 AM
iis smtp nntp: I am getting the message -2147467259 Method '~' of object '~' failed when I
try to attach a file into an email. The code is as follows

Set Mailer = CreateObject("CDONTS.Newmail")
Mailer.AttachFile zippedfilename
Mailer.To = EmailAddress
Mailer.From = EmailFrom
Mailer.Subject = Emailsubject
Mailer.Body = ""
Mailer.Send
Set Mailer = Nothing

The error happens on the second line. If I take this line away then the
email is sent successfully.

Re: CDONTS Attachfile error lankylad
9/16/2005 8:26:03 AM
I have changed the code to the following, but get the same error. The
zipfilename is a full path to the file

Dim Mailer
Set Mailer = CreateObject("CDONTS.Newmail")
Mailer.MailFormat = 0
Mailer.AttachFile zippedfilename, "Zipped File", 1
Mailer.To = EmailAddress
Mailer.From = Emailsubject
Mailer.Subject = Emailsubject
Mailer.Body = ""
Mailer.Send
Set Mailer = Nothing

[quoted text, click to view]
Re: CDONTS Attachfile error Al Mulnick
9/16/2005 11:00:20 AM
Syntax most likely. IIRC, you have to define three options with the
attachfile (path, name to display, encoding method).
Your zippedfilename attribute should equate to a full path to the file such
as "c:\temp\filename.zip" or similar.

Here's a nice walk through if it helps:
http://www.devguru.com/features/tutorials/CDONTS/cdonts.html

And the def for attachfile is:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/d3c6df90-b2d2-488d-aeed-de0396f0d7d1.asp

Al

[quoted text, click to view]

Re: CDONTS Attachfile error Al Mulnick
9/16/2005 3:16:51 PM
The syntax can be tricky when you do that. For now, how about substituting
the variable with the actual path name? Then, just to see the variable at
run time, try the following code (note the fix to the Mailer.From because
you would have the subject as the sender in your post :) Because you set
the attachment type, it's not necessary to set the Mailer.MailFormat
information. It'll default.

Set Mailer = CreateObject("CDONTS.NewMail")
Call Mailer.AttachFile("\\server\schedule\sched.xls", "SCHED.XLS",1)
Mailer.Send "Automated Schedule Generator", "user1@example.com", _
"Schedule", "Here's the new schedule", 0
Set Mailer = Nothing


This example comes from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/d3c6df90-b2d2-488d-aeed-de0396f0d7d1.asp
if you're interested.

Do you get the same results? Any particular reason you're writing this to a
2000 or older OS?


Al




[quoted text, click to view]

AddThis Social Bookmark Button