Solved

Send mail with attachment

Posted on 2000-05-10
12
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordpress display sub menu only when click 12 101
Html CheckBox obtain Its Value 5 43
Insert Button on a table 16 56
IIS 7 and executing pages using localhost 16 31
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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