Ok i have button that can send an attachment via email.. it launches outlook if its not open, creates an instance and attaches a file based on the populated hyperlink field in the record.. GREAT! What i want to do is then goto another record, press the button and it adds the second attachment based on that hyperlink field. currently when i do this, it adds another instance and does not attach it to the same email. how can i achieve this to say only open new item if item is not already open. here is my code.
Dim olApp As Object
Dim objMail As Object
Dim strPath As String
strPath = Me.Hyperlink 'Edit to your path
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open
If Err Then 'Outlook is not open
Set olApp = CreateObject("Outlook.Application") 'Create a new instance
End If
Set objMail = olApp.CreateItem(olMailItem)
With objMail
.BodyFormat = olFormatHTML
.To = ""
.Subject = ""
.HTMLBody = ""
.Attachments.Add (strPath)
.Send
.Display
End With
End Sub
Dim olApp As Object
Dim objMail As Object
Dim strPath As String
strPath = Me.Hyperlink 'Edit to your path
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open
If Err Then 'Outlook is not open
Set olApp = CreateObject("Outlook.Application") 'Create a new instance
End If
Set objMail = olApp.CreateItem(olMailItem)
With objMail
.BodyFormat = olFormatHTML
.To = ""
.Subject = ""
.HTMLBody = ""
.Attachments.Add (strPath)
.Send
.Display
End With
End Sub