rabbits2
asked on
Object doesn't support this property or method: 'AttachFile' using CDO email object
I am trying to send an attachment along with my email using CDO but I am getting the error message:
Object doesn't support this property or method: 'AttachFile'
Using this:
Set objCDOMail = Server.CreateObject("CDO.M essage")
objCDOMail.From = strFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.TextBody = strBody
objCDOMail.Cc = "info@purelifecoach.com"
objCDOMail.AttachFile =attachment
'objCDOMail.AddAttachment = attachment
objCDOMail.Send
Set objCDOMail = Nothing
Response.Write "Message sent to " & strTo & "!<br><br><br>"
Any ideas on why this might be al works fine (emails are sent) if I do not include that line:objCDOMail.AttachFile =attachment
Object doesn't support this property or method: 'AttachFile'
Using this:
Set objCDOMail = Server.CreateObject("CDO.M
objCDOMail.From = strFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.TextBody = strBody
objCDOMail.Cc = "info@purelifecoach.com"
objCDOMail.AttachFile =attachment
'objCDOMail.AddAttachment = attachment
objCDOMail.Send
Set objCDOMail = Nothing
Response.Write "Message sent to " & strTo & "!<br><br><br>"
Any ideas on why this might be al works fine (emails are sent) if I do not include that line:objCDOMail.AttachFile
ASKER
Tried this and get error message:
Object doesn't support this property or method: 'AddAttachment'
Any other ideas?
Object doesn't support this property or method: 'AddAttachment'
Any other ideas?
The ".Attachfile" method is associated with the "CDONTS" object, not the "CDO.Message" object.
With regards to the above, it should be ".AddAttachment". See the below for details:
http://www.w3schools.com/asp/asp_send_email.asp
With regards to the above, it should be ".AddAttachment". See the below for details:
http://www.w3schools.com/asp/asp_send_email.asp
you may need to set the CDO configuration in order to send an attachment, but the right coding for it is .AddAttachment
also please check that you are actually giving a value to your variable attachment.
If you can do this:
if attachment = "" OR ISNULL(attachment) then
response.write("There is nothing to attach")
else
response.write("There is an attachement")
end if
to just above Set objCDOMail = Server.CreateObject.... and then run the script it will show you if you are setting a value to attachment
check these links:
CDOSYS
http://www.w3schools.com/asp/asp_send_email.asp
http://www.codeproject.com/asp/cdoex.asp
http://quadcomm.com/tips/sendCDOSYSmail.txt
CDONTS:
http://www.4guysfromrolla.com/webtech/112298-1.shtml
http://authors.aspalliance.com/wiseasp/aboutemail.asp
please note that CDONTS was discontinued in windows 2003, and CDOSYS is now used.
also please check that you are actually giving a value to your variable attachment.
If you can do this:
if attachment = "" OR ISNULL(attachment) then
response.write("There is nothing to attach")
else
response.write("There is an attachement")
end if
to just above Set objCDOMail = Server.CreateObject.... and then run the script it will show you if you are setting a value to attachment
check these links:
CDOSYS
http://www.w3schools.com/asp/asp_send_email.asp
http://www.codeproject.com/asp/cdoex.asp
http://quadcomm.com/tips/sendCDOSYSmail.txt
CDONTS:
http://www.4guysfromrolla.com/webtech/112298-1.shtml
http://authors.aspalliance.com/wiseasp/aboutemail.asp
please note that CDONTS was discontinued in windows 2003, and CDOSYS is now used.
ASKER
I definity have a value in the variable attachment, that I've checked
Still getting the error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'AddAttachment'
You say I amy have to set the CDO configuration in order to send an attachment. How do I do this?
Still getting the error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'AddAttachment'
You say I amy have to set the CDO configuration in order to send an attachment. How do I do this?
you say the value is getting set, but if you do the check I suggested, you may find that it is not. Please do the check I suggested.
the second link I posted will show you how to set the configuration
the second link I posted will show you how to set the configuration
ASKER
I did run your test this is what I get:
There is an attachement
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'attachment.AddAttachment'
I have also used your link and added in the configuration lines like this:
if attachment = "" OR ISNULL(attachment) then
response.write("There is nothing to attach")
else
response.write("There is an attachement")
end if
Set objCDOMail = Server.CreateObject("CDO.M essage")
Set iConf = CreateObject("CDO.Configur ation")
Dim Flds
Set Flds = iConf.Fields
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Flds( _
"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") _
= "c:\inetpub\mailroot\picku p"
Flds.Update
Set objCDOMail.Configuration = iConf
objCDOMail.From = "info@caukus.com"
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.TextBody = strBody
objCDOMail.Cc = "info@purelifecoach.com"
'myMail.AddAttachment "c:\mydocuments\test.txt"
objCDOMail.AddAttachment = attachment
objCDOMail.Send
Set objCDOMail = Nothing
Response.Write "Message sent to " & strTo & "!<br><br><br>"
Anything else you can think of, would love to solve this, thanks.
There is an attachement
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'attachment.AddAttachment'
I have also used your link and added in the configuration lines like this:
if attachment = "" OR ISNULL(attachment) then
response.write("There is nothing to attach")
else
response.write("There is an attachement")
end if
Set objCDOMail = Server.CreateObject("CDO.M
Set iConf = CreateObject("CDO.Configur
Dim Flds
Set Flds = iConf.Fields
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Flds( _
"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") _
= "c:\inetpub\mailroot\picku
Flds.Update
Set objCDOMail.Configuration = iConf
objCDOMail.From = "info@caukus.com"
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.TextBody = strBody
objCDOMail.Cc = "info@purelifecoach.com"
'myMail.AddAttachment "c:\mydocuments\test.txt"
objCDOMail.AddAttachment = attachment
objCDOMail.Send
Set objCDOMail = Nothing
Response.Write "Message sent to " & strTo & "!<br><br><br>"
Anything else you can think of, would love to solve this, thanks.
the code is right.
the only other thing that I can say is try changing:
objCDOMail.AddAttachment = attachment
to:
objCDOMail.AddAttachment = "c:\mydocuments\test.txt"
or, try it with the =
the only other thing that I can say is try changing:
objCDOMail.AddAttachment = attachment
to:
objCDOMail.AddAttachment = "c:\mydocuments\test.txt"
or, try it with the =
ASKER
Not sure what you mean by:
or, try it with the =
Have tried using:
objCDOMail.AddAttachment = "c:\mydocuments\test.txt"
Inserting a correct path to an existing file on the server but still getting this same error: Object doesn't support this property or method: 'AddAttachment' .
Is this a common problem or is something feaking out for me? Not quite sure what steps to take next.
or, try it with the =
Have tried using:
objCDOMail.AddAttachment = "c:\mydocuments\test.txt"
Inserting a correct path to an existing file on the server but still getting this same error: Object doesn't support this property or method: 'AddAttachment' .
Is this a common problem or is something feaking out for me? Not quite sure what steps to take next.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
here's another link if you need some light reading :)
http://www.interlacken.com/winnt/tips/tipshow.aspx?tip=46
looks like with the AddAttachment method of CDO there is no need for the =
http://www.interlacken.com/winnt/tips/tipshow.aspx?tip=46
looks like with the AddAttachment method of CDO there is no need for the =
ASKER
Yes! Just found that out! It works if I use:
objCDOMail.AddAttachment "D:\webs\hushclothing.co.u k\html\ima ges3\one.g if "
and so does:
objCDOMail.AddAttachment attachment
All that over one =
Thanks for your help
objCDOMail.AddAttachment "D:\webs\hushclothing.co.u
and so does:
objCDOMail.AddAttachment attachment
All that over one =
Thanks for your help
:) anytime
thanks for the grade.
thanks for the grade.
I think the only reason the formatting ain't happening is due to the incorrect data value types.
I have attached the current SQL query im using.
The field that needs trimming is in table alias "a" with the column name "Intro_Date".
The field that needs formatting to currency is in the table alias "a" as well with column name "Price".
Both fields are of type varcher in SQL.
Hope this ain't to confusing.
Thanks
I have attached the current SQL query im using.
The field that needs trimming is in table alias "a" with the column name "Intro_Date".
The field that needs formatting to currency is in the table alias "a" as well with column name "Price".
Both fields are of type varcher in SQL.
Hope this ain't to confusing.
Thanks
SELECT a.*, b.Dealer_Name, c.make as vmake, c.Variant as vmodel, c.Intro_Date FROM Used_Stock a, Dealer b, Meads c
WHERE a.Company_Number = b.ID
AND a.Mead_Code = c.MCode
AND c.Make = @var_make
Ooops, added comment to wrong thread :P
Please remove any of my comments from this thread
Thanks
Please remove any of my comments from this thread
Thanks
objCDOMail.AddAttachment = attachment