L
ldiaz
I already posted this question but I did get any answer.
I have a module to send attachments (below mentioned) and I have this code
on my click event (below mentioned), all works fine, but I would like also
add an access report named:rpt_Broker, how can I do that?
Thanks in advanced.
'Click event on my Button on my form
'======================
Private Sub EmailReport_Click()
Dim strfile As String
strfile = Me.[Path_Loc]
sbSendMessage (strfile)
End sub
'===========
module code
'=====================================
Sub sbSendMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
On Error GoTo ErrorMsgs
' 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. Substitute
' your names here.
'Set objOutlookRecip = .Recipients.Add(EmailCust)
Set objOutlookRecip =
..Recipients.Add([Forms]![Frm_Broker]![Customer_Email])
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip =
..Recipients.Add([Forms]![Frm_Broker]![Customer_DL])
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Check attachment for more information about received
products"
.Body = "Received products." & vbCrLf & vbCrLf & _
"CLD warehouse and service" & vbCrLf & _
"Tel: (619)-9704515" & vbCrLf & _
"Fax: (619)-4582282"
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Display
' .Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. For more information" & _
"see the document at http://www.microsoft.com/office" & _
"/previous/outlook/downloads/security.asp. "
Else
MsgBox Err.Number, Err.Description
End If
End Sub
'======================================
I have a module to send attachments (below mentioned) and I have this code
on my click event (below mentioned), all works fine, but I would like also
add an access report named:rpt_Broker, how can I do that?
Thanks in advanced.
'Click event on my Button on my form
'======================
Private Sub EmailReport_Click()
Dim strfile As String
strfile = Me.[Path_Loc]
sbSendMessage (strfile)
End sub
'===========
module code
'=====================================
Sub sbSendMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
On Error GoTo ErrorMsgs
' 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. Substitute
' your names here.
'Set objOutlookRecip = .Recipients.Add(EmailCust)
Set objOutlookRecip =
..Recipients.Add([Forms]![Frm_Broker]![Customer_Email])
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip =
..Recipients.Add([Forms]![Frm_Broker]![Customer_DL])
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Check attachment for more information about received
products"
.Body = "Received products." & vbCrLf & vbCrLf & _
"CLD warehouse and service" & vbCrLf & _
"Tel: (619)-9704515" & vbCrLf & _
"Fax: (619)-4582282"
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Display
' .Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. For more information" & _
"see the document at http://www.microsoft.com/office" & _
"/previous/outlook/downloads/security.asp. "
Else
MsgBox Err.Number, Err.Description
End If
End Sub
'======================================