Solved

Send mail with attachment

Posted on 2000-05-10
12
338 Views
Last Modified: 2008-02-20
I'm trying the same thing as another mail I see down here. But I can't even get the attachment to work from the server.
When using the "objSendMail.AttachFile" I get the error:
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'AttachFile'

Is there any setting somwhere (that I can't find) to get the attachment to work?
I guess I'm one step behind the other guy.. I got the upload part done..
The problem is to attach a file in the mail.
This is my current code:
Dim objSendMail
Set objSendMail = CreateObject("CDONTS.NewMail")
            
objSendMail.From = From
objSendMail.To = Till
objSendMail.Cc = cc
objSendMail.Bcc = Bcc
objSendMail.Subject = Subject
objSendMail.Body = Message
objSendMail.AttachFile = filename
                        
objSendMail.Send

Set objSendMail = Nothing

Why do I get that the AttachFile is not valid?

Thanks,
~Gizmo
0
Comment
Question by:Gizmo
12 Comments
 
LVL 8

Expert Comment

by:xabi
ID: 2796601
Are you providing the right path to the file?

xabi
0
 

Author Comment

by:Gizmo
ID: 2796699
It does not matter what I write there... If i put the path to "c:\config.sys" it still gives the same error..
0
 
LVL 1

Expert Comment

by:eladr
ID: 2797538
did you put the sending mail code inside
a loop or something?
eladr
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Expert Comment

by:Bardel
ID: 2797761
Hi Gizmo,

I've used CDONTS to send mail in HTML format using the following code, the only difference is that I use .AttachURL to attach an inline image (in the HTML) but it works to attach a non referenced file too.


Dim myMail
Set myMail = CreateObject("CDONTS.NewMail")
 
myMail.From = "address@company.com"
myMail.To = "address@company.co.uk"
myMail.Subject = "HTML Mail"
myMail.BodyFormat = cdoBodyFormatHTML
myMail.MailFormat = cdoMailFormatMime
myMail.Body = HTMLCodeHere

' Attach all inline images referred above to the message.....
myMail.AttachURL "D:\Inetpub\wwwroot\images\rtype.gif", "RType.gif"

myMail.Send
Set myMail = Nothing
0
 

Expert Comment

by:urbana
ID: 2797924
Use objSendMail.AttachFile(filename) since AttachFile is a method of CDONTS NewMail object, not a property.

Urbana

0
 

Author Comment

by:Gizmo
ID: 2799148
The objSendMail.AttachFile(filename) is the way to do it.. But if I use it that way I get the extremly good error message:

error '80004005'
Unspecified error

/sendmail.asp, line 74

I'm thinking if lines if symbols like : and \ or . is causing the error?

is it?

I think it's strange anyway...
I'm lost!
0
 
LVL 2

Accepted Solution

by:
bbala earned 50 total points
ID: 2800185
pass the value to the following fn and try the following code. this is especially useful when u have to attach more than i file...

Note here  request.form("getName") is
like "c:\temp\x.txt*c:\temp\y.txt"

request.form("getName") is
like "x.txt y.txt"

sub Sendmail(fromwho,towho,subject,BodyData,tocc)
dim mymail
set mymail=server.CreateObject "CDONTS.Newmail")
mymail.from=fromwho
mymail.to=towho
mymail.cc=tocc
mymail.subject=subject
mymail.body=BodyData
if Request.Form("getName")<>"" then
if instr(Request.Form("getName"),"*")>0 then  
a=split(Request.Form("getName"),"*")
b=split(Request.Form("BFAttch")," ")      
 for i =0 to ubound(a)
 if instr(Request.Form("getName"),b(i))>0 then  
 if trim(b(i))<>"" then
 mymail.AttachFile  a(i)',mid(a(i),instr(right(a(i)),"\"))
  end if
end if      
next
else
mymail.AttachFile  Request.Form("getName") ',mid(Request.Form("getName"),instr(right(Request.Form("getName")),"\"))
end if
end if              
mymail.send
Msg="Mail Successfully sent"
set mymail=nothing
end sub
0
 

Expert Comment

by:Kinkz
ID: 2922480
I'm having exactly the same difficulty in understanding this as Gizmo.  Why is there a function
objSendMail.AttachFile(filename)
in the first place if you have to find a new way to use it ?
0
 
LVL 2

Expert Comment

by:bbala
ID: 2924812
CDONTS  does not support the attachment of more than one file with
"," seperator as like the ordinary attachments.

 That's why we have to do it like adding one by one as i have done above.
 It works fine for me
0
 

Author Comment

by:Gizmo
ID: 3273517
Answer accepted
0
 

Author Comment

by:Gizmo
ID: 3273518
Thank's for the help..

I'm using JMail that are working much better!.. =)

~Gizmo
0
 

Expert Comment

by:malkuchi
ID: 4480359
can any one please post the complete soluton of sending a file as attachment using cdonts,

<%
   SET myMail = Server.CreateObject("CDONTS.Newmail")
             myMail.BodyFormat = cdoBodyFormatHTML
             myMail.MailFormat = cdoMailFormatMime
             myMail.From = "malkuchi@yahoo.com"
             myMail.To = "malkuchi@yahoo.com"
           myMail.Subject = "Testing Subject "
           myMail.Body = "this is body"
             myMail.AttachURL ("GetStarted.gif","image.gif" )
           myMail.Send
     SET myMail = NOTHING
%>

also I tried above attach method without parenthesis, but not working the gif specified is on the same location on my server where this code is present
if some body know it please provide complete code
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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