Solved

Send mail with attachment

Posted on 2000-05-10
12
335 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

27 Experts available now in Live!

Get 1:1 Help Now