Solved

Send mail with attachment

Posted on 2000-05-10
12
336 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft SQL ADO Conn Issue 6 47
ASP/VB email question 4 34
Passing Parameter to Stored Procedure 4 24
Hide cell in a table 2 12
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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