IIS and SMTP - CDONTS Attachfile error

This is Interesting: Free IT Magazines  
Home > Archive > IIS and SMTP > September 2005 > CDONTS Attachfile error





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author CDONTS Attachfile error
lankylad

2005-09-16, 6:00 pm

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.

Any ideas?
Al Mulnick

2005-09-16, 6:00 pm

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/tut...NTS/cdonts.html

And the def for attachfile is:
http://msdn.microsoft.com/library/d...e0396f0d7d1.asp

Al

"lankylad" <lankylad@discussions.microsoft.com> wrote in message
news:A33EAE6B-C25D-4AF1-BC89-24A66B000B68@microsoft.com...
>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.
>
> Any ideas?



lankylad

2005-09-16, 6:00 pm

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

"Al Mulnick" wrote:

> 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/tut...NTS/cdonts.html
>
> And the def for attachfile is:
> http://msdn.microsoft.com/library/d...e0396f0d7d1.asp
>
> Al
>
> "lankylad" <lankylad@discussions.microsoft.com> wrote in message
> news:A33EAE6B-C25D-4AF1-BC89-24A66B000B68@microsoft.com...
>
>
>

Al Mulnick

2005-09-16, 6:00 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/d...e0396f0d7d1.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




"lankylad" <lankylad@discussions.microsoft.com> wrote in message
news:FC042128-105C-4DBF-A825-0EEA38A9154B@microsoft.com...[vbcol=seagreen]
>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
>
> "Al Mulnick" wrote:
>


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com