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] "lankylad" <lankylad@discussions.microsoft.com> wrote in message
news:FC042128-105C-4DBF-A825-0EEA38A9154B@microsoft.com...
>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/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
>>
>> "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?
>>
>>
>>