J
Jani
From code found on this site (sorry, do not have who provided it but it was
one of the super mvps) and I've gotten as far as creating the e-mail needed
to send an object. My issue is that if the e-mail is canceled, a message is
displayed 'The SendObject action was canceled.' which I do not want to be
displayed or to change the message to something like 'E-mail canceled.' Below
is the entire code which is rather long but thought it best to include all of
it. Thanks in advance for your help! Jani
Private Sub cmdEmailMgr_Click()
On Error GoTo cmdEMailMgr_Click_Err
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim StrCriterion As String
Dim strMailto As String
Dim strSubject As String
Dim strDocName As String
'This forces the record to be saved.
DoCmd.RunCommand acCmdSaveRecord
'There is no need to check if the form is blank (as with report and preview)
as the cmdEmailReport button will
'only be enabled if there is and e-mail address in CustomerEMailAddress field.
'If there is nothing in the subject control (CustomerEMailSubject) then the
subject field in the e-mail client
'will display the name of the report.
If IsNull(Me!TaskShort) Or Me!TaskShort = "" Then
strMailto = Me.EmailAddress1
strDocName = "rpt_WorkOrder"
' StrCriterion = " [CustomerID]=" & Forms![Frm_Customer].[CustomerID]
'This will hide the customer form
Me.Visible = False
' This will open the report with the same primary key as the form on the
screen.In preview mode
' DoCmd.OpenReport "rpt_WorkOrder", acPreview, , StrCriterion
'This will minimize the report, whilst the e-mail in being prepared, I have
tried not to have it open in preview but
'cannot get it to work.
DoCmd.Minimize
'This will create the e-mail
DoCmd.SendObject acReport, strDocName, "RichTextFormat(*.rtf)", strMailto,
"", "", strDocName, , True, ""
'Tbis explains all the section of the e-mail see SendObject in help
'Explanation DoCmd.SendObject [objecttype][, objectname][,
outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][,
templatefile]
Else
'If there is something in the subject control (CustomerEMailSubject) then
the subject field in the e-mail client
'will display that data.
strMailto = Me.EmailAddress1
strSubject = "New NonPM Work Order: " & Me.[ID #] & " " & Me.TaskShort
strDocName = "rpt_WorkOrder"
' StrCriterion = " [CustomerID]=" & Forms![Frm_Customer].[CustomerID]
'This will hide the customer form
Me.Visible = False
' DoCmd.OpenReport "rpt_WorkOrder", acPreview, , StrCriterion
'This will minimize the report, whilst the e-mail in being prepared, I have
tried not to have it open in preview but
'cannot get it to work.
' DoCmd.Minimize
'This will create the e-mail
DoCmd.SendObject acReport, strDocName, "RichTextFormat(*.rtf)", strMailto,
"", "", strSubject, , True, ""
'Tbis explains all the section of the e-mail see SendObject in help
'Explanation DoCmd.SendObject [objecttype][, objectname][,
outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][,
templatefile]
End If
'This will close the report when you either cancel or send the e-mail. The
Frm_Customer will open
DoCmd.CLOSE acReport, "rpt_WorkOrder"
'cmdEmailMgr:
'If Err.Number = 2501 Then
' MsgBox "This email message has not been sent. E-mail message has
been cancelled"
' End If
cmdEMailMgr_Click_Exit:
Exit Sub
cmdEMailMgr_Click_Err:
MsgBox Error$
Resume cmdEMailMgr_Click_Exit
End Sub
one of the super mvps) and I've gotten as far as creating the e-mail needed
to send an object. My issue is that if the e-mail is canceled, a message is
displayed 'The SendObject action was canceled.' which I do not want to be
displayed or to change the message to something like 'E-mail canceled.' Below
is the entire code which is rather long but thought it best to include all of
it. Thanks in advance for your help! Jani
Private Sub cmdEmailMgr_Click()
On Error GoTo cmdEMailMgr_Click_Err
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim StrCriterion As String
Dim strMailto As String
Dim strSubject As String
Dim strDocName As String
'This forces the record to be saved.
DoCmd.RunCommand acCmdSaveRecord
'There is no need to check if the form is blank (as with report and preview)
as the cmdEmailReport button will
'only be enabled if there is and e-mail address in CustomerEMailAddress field.
'If there is nothing in the subject control (CustomerEMailSubject) then the
subject field in the e-mail client
'will display the name of the report.
If IsNull(Me!TaskShort) Or Me!TaskShort = "" Then
strMailto = Me.EmailAddress1
strDocName = "rpt_WorkOrder"
' StrCriterion = " [CustomerID]=" & Forms![Frm_Customer].[CustomerID]
'This will hide the customer form
Me.Visible = False
' This will open the report with the same primary key as the form on the
screen.In preview mode
' DoCmd.OpenReport "rpt_WorkOrder", acPreview, , StrCriterion
'This will minimize the report, whilst the e-mail in being prepared, I have
tried not to have it open in preview but
'cannot get it to work.
DoCmd.Minimize
'This will create the e-mail
DoCmd.SendObject acReport, strDocName, "RichTextFormat(*.rtf)", strMailto,
"", "", strDocName, , True, ""
'Tbis explains all the section of the e-mail see SendObject in help
'Explanation DoCmd.SendObject [objecttype][, objectname][,
outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][,
templatefile]
Else
'If there is something in the subject control (CustomerEMailSubject) then
the subject field in the e-mail client
'will display that data.
strMailto = Me.EmailAddress1
strSubject = "New NonPM Work Order: " & Me.[ID #] & " " & Me.TaskShort
strDocName = "rpt_WorkOrder"
' StrCriterion = " [CustomerID]=" & Forms![Frm_Customer].[CustomerID]
'This will hide the customer form
Me.Visible = False
' DoCmd.OpenReport "rpt_WorkOrder", acPreview, , StrCriterion
'This will minimize the report, whilst the e-mail in being prepared, I have
tried not to have it open in preview but
'cannot get it to work.
' DoCmd.Minimize
'This will create the e-mail
DoCmd.SendObject acReport, strDocName, "RichTextFormat(*.rtf)", strMailto,
"", "", strSubject, , True, ""
'Tbis explains all the section of the e-mail see SendObject in help
'Explanation DoCmd.SendObject [objecttype][, objectname][,
outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][,
templatefile]
End If
'This will close the report when you either cancel or send the e-mail. The
Frm_Customer will open
DoCmd.CLOSE acReport, "rpt_WorkOrder"
'cmdEmailMgr:
'If Err.Number = 2501 Then
' MsgBox "This email message has not been sent. E-mail message has
been cancelled"
' End If
cmdEMailMgr_Click_Exit:
Exit Sub
cmdEMailMgr_Click_Err:
MsgBox Error$
Resume cmdEMailMgr_Click_Exit
End Sub