Sorry if this has been asked a bunch of times already. I couldn't find anything specific to my question.
I'm using the following code to open a pdf:
Using Application.FollowHyperlink Me![Text39]
[text39] is simply the path name. This is working great. The actual file name that is part of the path name equals the records autonumber field name, so it's quite easy to reference them.
Now is there a way to email this same pdf file using a similar setup but with the sendobjects command? I'd also like to be able to send multiple attached pdf's if necesary. If anyone knows of the most simplest way of doing this please let me know. Thanks.
here is code that works in 2000 using the outlook object model for 2000
you should be able to use the outlook 8.0 object model without a problem
Sub SendMessage(Optional AttachmentPath)
On Error GoTo mymailerror
Dim fs As FileSystemObject
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim strconemail As String
'This dim statement gets the email address from a table that matches the id on my form
strconemail = DLookup("[email]", "tblconmaster", _
"conid = forms!frmrange!conid")
Dim mysubject As String
Set fs = New FileSystemObject
mysubject = "Any thing you want"
mypath = "C:\pdf\" & Forms!myformname!myid & ".pdf" 'you can use you own pathing mechanism here I hardcoded a path for you
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Set objOutlookRecip = .Recipients.Add(strconemail)
objOutlookRecip.Type = olTo
Set objOutlookRecip = .Recipients.Add("firstname.lastname@example.org") 'sends me a copy
If MsgBox("Are you going to CC another party?", vbYesNo, _
"CC 3rd Party") = vbYes Then
Dim strmycc As String
strmycc = InputBox("Enter One additional CC", "Add CC to List")
Set objOutlookRecip = .Recipients.Add(strmycc)
objOutlookRecip.Type = olCC
.Subject = mysubject
mybodyadd = InputBox("Additional notes", "Add More Notes")
.Body = "There are attachments with this email." & vbCrLf & vbCrLf & _
mybodyadd & vbCrLf & vbCrLf & "A Pdf file is attached"
.Importance = olImportanceHigh 'High importance
If Not IsMissing(mypath) Then
Set objOutlookAttach = .Attachments.Add(mypath)
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
MsgBox "Your email has been sent to " & strconemail
If Err.Number = 0 Then
MsgBox Err.Number & vbCrLf & vbCrLf & Err.Description
I use this with pre sr1 release of office 2k so I do not get the outlook patch alerts that says i have a program that is sending an email
the cdo code I gave you bypasses that altogether regardless of versions and service releases.