Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

emailing with an attachment

Status
Not open for further replies.

stever1725

Technical User
Feb 12, 2009
13
US
Anyone who could help.. i have researched but cannot seem to get this resolved. i am getting **Run-Time error '450' Wrong number of arguments or invalid property assignment** on debug the .Attachment line is highlighted. Can somenone give me some insight to this? if i take out this line i do get an email sent.. i need to be able to attach a file. please help. thanks steve


Option Compare Database

Public Function mailtest()

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1
Set Flds = iConf.Fields
With Flds
.Item(" = 2
.Item(" = "mailserver.test.net"
.Item(" = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "sgarcia@test.com"
.BCC = ""
.From = """Steve Garcia"" <test@test.net>"
.Subject = "Test Email"
.TextBody = "This is a test"
.Attachments.Add "C:\CPASO.xls", olByValue, 1
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

End Function
 
I have used almost similar code but

.AddAttachment "C:\CPASO.xls"

rather than

.Attachments.Add "C:\CPASO.xls", olByValue, 1


 
Have a look here:
thread705-1369407

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks Irish and PHV... i changed the .Attach to .AddAtt and the email with attachment went out. The thread705 helps as well. Thanks again... i will keep tryn to do my part and help out others as well. peace
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top