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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sendobject and attachments

Status
Not open for further replies.

Digsys

Technical User
Jun 27, 2002
170
AU
Does anyone know if it is possible to send a word doc as an attachment when sending emails from access using the sendobject method??
 
I found this on another thread. I was looking for the code myself





You can't with SendObject.
If you use Outlook (not Outlook Express), then it can be done like below:

Sub SendAttachedFile(FileNameAndPath$, AttachDescr$, ToAdds$, CCAdds$, BCCAdds$, SubjectLine$, MsgBody$)

Dim myOlApp, MyItem, MyAttachments
Set myOlApp = CreateObject("Outlook.Application")
Set myItem=myOlApp.CreateItem(olMailItem)

With myItem
.To = ToAdds
.CC = CCAdds
.BCC = BCCAdds
.Subject = SubjectLine
.Body = MsgBody
.Attachments.Add FileNameAndPath, olByValue, 1, AttachDescr
.Display 'this will display the result
.Send 'this will place the message immediately to Outbox
End With

set myItem = Nothing
MyOlApp.Close
Set myOlApp = Nothing
End Sub

All procedure arguments should be provided by text boxes on your form.
The procedure can be called from a command button:

Private YourButton_Click()
'whatever code you want to execute before sending the mail
Call SendAttachedFile(Me("FileTextBox"), Me("FileDescription"), Me("ToAddresses"), Me("CCAddresses"), Me("BCCAddresses"), Me("Subject"), Me("Body"))
End Sub

HTH


Daniel Vlas
Systems Consultant
danvlas@yahoo.com

Neil Berryman
IT Trainer
neil_berryman@btopenworld.com


 
Thanks daniel. I have given up on sendobject and have used CDONTS which is fantastic so long as you are using W2000 or NT. I still have a minot problem with it though!. It does not report any errors, even if the internet is not connected. Does anyone have any thoughts on this??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top