Solved

Send mail with attachment

Posted on 2000-05-10
12
334 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
Comment Utility
Are you providing the right path to the file?

xabi
0
 

Author Comment

by:Gizmo
Comment Utility
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
Comment Utility
did you put the sending mail code inside
a loop or something?
eladr
0
 

Expert Comment

by:Bardel
Comment Utility
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
Comment Utility
Use objSendMail.AttachFile(filename) since AttachFile is a method of CDONTS NewMail object, not a property.

Urbana

0
 

Author Comment

by:Gizmo
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Accepted Solution

by:
bbala earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Answer accepted
0
 

Author Comment

by:Gizmo
Comment Utility
Thank's for the help..

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

~Gizmo
0
 

Expert Comment

by:malkuchi
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

10 Experts available now in Live!

Get 1:1 Help Now