how send an access report besides a C:\attachment already included

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
'======================================
 
W

Wayne-I-M

Export your report and add the path to the module.

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

End If

Example
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

would be
Set objOutlookAttach = .Attachments.Add("C:\Documents and Settings\My Documents\rpt_Broker.doc")



--
Wayne
Manchester, England.



ldiaz said:
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
'======================================
 
L

ldiaz

Hi Wayne,

it's working fine..

Thanks a lot
--
Lorenzo Díaz
Cad Technician


Wayne-I-M said:
Export your report and add the path to the module.

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

End If

Example
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

would be
Set objOutlookAttach = .Attachments.Add("C:\Documents and Settings\My Documents\rpt_Broker.doc")



--
Wayne
Manchester, England.



ldiaz said:
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
'======================================
 
L

ldiaz

another question.

I need to update a field in the main form named:Sent_EmailDate
I put this code after the Display, the problem is that: if I decide to
cancel the email, it update the field as well, I need it update only if the
e-mail is sent, if was not sent then the Sent_EmailDate field should remain
blank.

please advise.

'part of the module code.
'==========================
Next
.Display
' .Send

[Forms]![Frm_Broker]![Sent_EmailDate].Value = Format(Now(), "Mmm-dd-yy
hh:nn:ss Am/Pm")

Set objOutlookMsg = Nothing
Set objOutlook = Nothing--
'here continue the module code.
======================

Lorenzo Díaz
Cad Technician


Wayne-I-M said:
Export your report and add the path to the module.

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

End If

Example
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

would be
Set objOutlookAttach = .Attachments.Add("C:\Documents and Settings\My Documents\rpt_Broker.doc")



--
Wayne
Manchester, England.



ldiaz said:
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
'======================================
 
W

Wayne-I-M

If you have a table field to record this ?? I would not include it into the
module but rather make a it a seperate function (private sub as opposed to a
public one)

You could just use date() (or Now() if it is important to know the exact
time - add the details to a bound table field with the same on click as the
send object.

The reason for not adding it to the module (this bit is up to you) as I
would include the report export into this. You may then not to send the mail
and if the Now() in the module you will have a recorded a mail that was not
sent


--
Wayne
Manchester, England.



ldiaz said:
another question.

I need to update a field in the main form named:Sent_EmailDate
I put this code after the Display, the problem is that: if I decide to
cancel the email, it update the field as well, I need it update only if the
e-mail is sent, if was not sent then the Sent_EmailDate field should remain
blank.

please advise.

'part of the module code.
'==========================
Next
.Display
' .Send

[Forms]![Frm_Broker]![Sent_EmailDate].Value = Format(Now(), "Mmm-dd-yy
hh:nn:ss Am/Pm")

Set objOutlookMsg = Nothing
Set objOutlook = Nothing--
'here continue the module code.
======================

Lorenzo Díaz
Cad Technician


Wayne-I-M said:
Export your report and add the path to the module.

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

End If

Example
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

would be
Set objOutlookAttach = .Attachments.Add("C:\Documents and Settings\My Documents\rpt_Broker.doc")



--
Wayne
Manchester, England.



ldiaz said:
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
'======================================
 
L

ldiaz

yes I have a field on my form named:Sent_EmailDate connected to a table.
I also added after sbSendMessage function on my click event of button, but
it does not work, since it does not update anything on my field on my form.


Private Sub EmailReport_Click()
Dim strfile As String
strfile = Me.[Path_Loc]
'this is the function to send the e-mail
sbSendMessage (strfile)

''This code here does not work
Sent_EmailDate].Value = Format(Now(), "Mmm-dd-yy hh:nn:ss Am/Pm")


End sub



thanks
--
Lorenzo Díaz
Cad Technician


Wayne-I-M said:
If you have a table field to record this ?? I would not include it into the
module but rather make a it a seperate function (private sub as opposed to a
public one)

You could just use date() (or Now() if it is important to know the exact
time - add the details to a bound table field with the same on click as the
send object.

The reason for not adding it to the module (this bit is up to you) as I
would include the report export into this. You may then not to send the mail
and if the Now() in the module you will have a recorded a mail that was not
sent


--
Wayne
Manchester, England.



ldiaz said:
another question.

I need to update a field in the main form named:Sent_EmailDate
I put this code after the Display, the problem is that: if I decide to
cancel the email, it update the field as well, I need it update only if the
e-mail is sent, if was not sent then the Sent_EmailDate field should remain
blank.

please advise.

'part of the module code.
'==========================
Next
.Display
' .Send

[Forms]![Frm_Broker]![Sent_EmailDate].Value = Format(Now(), "Mmm-dd-yy
hh:nn:ss Am/Pm")

Set objOutlookMsg = Nothing
Set objOutlook = Nothing--
'here continue the module code.
======================

Lorenzo Díaz
Cad Technician


Wayne-I-M said:
Export your report and add the path to the module.


' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

End If


Example
Set objOutlookAttach = .Attachments.Add(AttachmentPath)

would be

Set objOutlookAttach = .Attachments.Add("C:\Documents and Settings\My Documents\rpt_Broker.doc")



--
Wayne
Manchester, England.



:

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
'======================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top