Eightball3
Programmer
I think I'm close to figuring this out. I'm trying to set my application up so that when a button is pushed a report is attached to email and sent. I have everything working except the attachment part. How do you tell Outlook that you want to attach an Access Report? I get the message that the report is not open. Here is what I have:
Sub SendMessage_Mail(Optional AttachmentPath)
Dim Message As String
Dim CC As String
Dim Sbjct As String
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
CC = "test"
Sbjct = "test"
Message = "test"
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application"
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.add("test"
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
If CC = "" Then
Else
Set objOutlookRecip = .Recipients.add(CC)
objOutlookRecip.Type = olCC
End If
' Set the Subject, Body, and Importance of the message.
.Subject = Sbjct
.Body = Message
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
'Set objOutlookAttach = .Attachments.add([Reports]![Report])
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Display
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
Can anyone help me out here? Thanks
Sub SendMessage_Mail(Optional AttachmentPath)
Dim Message As String
Dim CC As String
Dim Sbjct As String
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
CC = "test"
Sbjct = "test"
Message = "test"
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application"
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.add("test"
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
If CC = "" Then
Else
Set objOutlookRecip = .Recipients.add(CC)
objOutlookRecip.Type = olCC
End If
' Set the Subject, Body, and Importance of the message.
.Subject = Sbjct
.Body = Message
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
'Set objOutlookAttach = .Attachments.add([Reports]![Report])
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Display
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
Can anyone help me out here? Thanks