Sending Report via Email

B

Bob Vance

My Db has 2 ways of sending a report via email
(1) OwnerStatement, which just creates the email, then you manually send it
(2) Invoice , which sends the report via email on deactivate, I am trying to
get Invoice to just create the email and then you can send it manually like
ownerStatement
Thanks in advance for any help with this......Bob

Both codes are listed below
--------------------------------------------------------
Private Sub SendMailButton_Click()
On Error GoTo ErrorHandler
Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, sndReport As String, strCompany As String
Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp As
Integer

Select Case Me.OpenArgs
Case "OwnerStatement"
sndReport = "rptOwnerPaymentMethod"

lngID = Nz(Me.cbOwnerName.Column(0), 0)
strMail = OwnerEmailAddress(lngID)

strBodyMsg = "Dear "
strBodyMsg = strBodyMsg & Nz(DLookup("[ClientTitle]",
"tblOwnerInfo", _
"[OwnerID]=" & lngID), " ") & " "
strBodyMsg = strBodyMsg & Nz(DLookup("[OwnerLastName]",
"tblOwnerInfo", _
"[OwnerID]=" & lngID), " Owner")
strBodyMsg = strBodyMsg & "," & Chr(10) & Chr(10) & Chr(13) _
& "Attached is your Statement for the period from " &
Format(Me.tbDateFrom, "d-mmm-yy") _
& " to " & Format(Me.tbDateTo, "d-mmm-yy") & "." _
& eMailSignature("Best Regards", True) & Chr(10) & Chr(10) _
& DownloadMessage("rtf")


DoCmd.SendObject acSendReport, sndReport, acFormatRTF, strMail,
, , "Your Statement", _
strBodyMsg, True

Case Else
Exit Sub

End Select
Exit Sub

ErrorHandler:

msgTitle = "Untrapped Error"
msgBtns = vbExclamation
If Err.Number = 2501 Then 'Prevent error when send is canceled
Err.Clear
Exit Sub
End If
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description & Chr(13) & Chr(13) _
& "(frmBillStatement SendMailButton_Click)", msgBtns, msgTitle


End Sub
---------------------------------------------------------------------------------
Private Sub Report_Deactivate()

On Error GoTo Error_Handler

Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, dtInvDate As Date, varInvNum As Variant, _
idHorse As Long, strHorse As String


Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp
As Integer

If CurrentProject.AllForms("frmModify").IsLoaded = True Then
lngID = DLookup("OwnerID", "tblInvoice", "InvoiceID = " _
& Form_frmModify.lstModify.Column(0))
ElseIf CurrentProject.AllForms("frmModifyInvoiceClient").IsLoaded = True
Then
lngID = DLookup("OwnerID", "tblInvoice", "InvoiceID = " _
& Form_frmModifyInvoiceClient.lstModify.value)
Else
Exit Sub
End If

strMail = Nz(DLookup("Email", "tblOwnerInfo", "OwnerID = " & lngID), "")

If Not IsEmailOn Or Not IsOwnerWithEmail(lngID) Then
Exit Sub
End If

dtInvDate = Me.tbInvoiceDate
varInvNum = Me.tbInvoiceNumber
idHorse = Nz(Me.tbHorseID, 0)
If idHorse <> 0 Then
strHorse = Nz(DLookup("[HorseName]", "tblHorseInfo", "[HorseID]=" &
idHorse), "")
Else
strHorse = ""
End If

strBodyMsg = "Dear "
strBodyMsg = strBodyMsg & Nz(DLookup("[ClientTitle]", "tblOwnerInfo",
"[OwnerID]=" & lngID), " ") & " "
strBodyMsg = strBodyMsg & Nz(DLookup("[OwnerLastName]", "tblOwnerInfo",
"[OwnerID]=" & lngID), " Owner")
strBodyMsg = strBodyMsg & "," & Chr(10) & Chr(10) & Chr(13) _
& "Attached is your " & varInvNum & " Dated " & Format(dtInvDate,
"d-mmm-yyyy") _
& IIf(Len(strHorse) > 0, " for " & strHorse, "") & "." _
& eMailSignature("Best Regards", True) & Chr(10) & Chr(10) & Chr(13) _
& DownloadMessage("rtf")



If strMail = "Null" Or Len(strMail) = 0 Or _
DLookup("[MailFlag]", "tblAdminSetup") = False Then
Exit Sub
End If

DoCmd.SendObject acSendReport, Me.Name, acFormatRTF, strMail, , , "Your
Invoice", _
strBodyMsg, blEditMail


Exit Sub


If MsgBox("Do you want to send Email??", vbYesNo + vbDefaultButton2)
= vbYes Then

DoCmd.SendObject acSendReport, Me.Name, acFormatRTF,
strMail, , , _
"Your Invoice", strBodyMsg, True ' ** Change to "False"
later
End If

Exit Sub

Error_Handler:
Select Case Err.Number
Case 2501
Case 2487
Resume Next
Case Else
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description, , "Untrapped Error"

End Select

End Sub
 
P

Pete D.

You need the last paramiter, Don't know what blEditMail is set by but I
select it is in your button that calls the report. Change it to True.Edit
Message Specifies whether the message can be edited before it's sent. If you
select Yes, the electronic mail application starts automatically, and the
message can be edited. If you select No, the message is sent without the
user having a chance to edit the message. The default is Yes.




Bob Vance said:
My Db has 2 ways of sending a report via email
(1) OwnerStatement, which just creates the email, then you manually send
it
(2) Invoice , which sends the report via email on deactivate, I am trying
to get Invoice to just create the email and then you can send it manually
like ownerStatement
Thanks in advance for any help with this......Bob

Both codes are listed below
--------------------------------------------------------
Private Sub SendMailButton_Click()
On Error GoTo ErrorHandler
Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, sndReport As String, strCompany As String
Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp
As Integer

Select Case Me.OpenArgs
Case "OwnerStatement"
sndReport = "rptOwnerPaymentMethod"

lngID = Nz(Me.cbOwnerName.Column(0), 0)
strMail = OwnerEmailAddress(lngID)

strBodyMsg = "Dear "
strBodyMsg = strBodyMsg & Nz(DLookup("[ClientTitle]",
"tblOwnerInfo", _
"[OwnerID]=" & lngID), " ") & " "
strBodyMsg = strBodyMsg & Nz(DLookup("[OwnerLastName]",
"tblOwnerInfo", _
"[OwnerID]=" & lngID), " Owner")
strBodyMsg = strBodyMsg & "," & Chr(10) & Chr(10) & Chr(13) _
& "Attached is your Statement for the period from " &
Format(Me.tbDateFrom, "d-mmm-yy") _
& " to " & Format(Me.tbDateTo, "d-mmm-yy") & "." _
& eMailSignature("Best Regards", True) & Chr(10) & Chr(10) _
& DownloadMessage("rtf")


DoCmd.SendObject acSendReport, sndReport, acFormatRTF,
strMail, , , "Your Statement", _
strBodyMsg, True

Case Else
Exit Sub

End Select
Exit Sub

ErrorHandler:

msgTitle = "Untrapped Error"
msgBtns = vbExclamation
If Err.Number = 2501 Then 'Prevent error when send is canceled
Err.Clear
Exit Sub
End If
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description & Chr(13) & Chr(13) _
& "(frmBillStatement SendMailButton_Click)", msgBtns, msgTitle


End Sub
---------------------------------------------------------------------------------
Private Sub Report_Deactivate()

On Error GoTo Error_Handler

Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, dtInvDate As Date, varInvNum As Variant, _
idHorse As Long, strHorse As String


Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp
As Integer

If CurrentProject.AllForms("frmModify").IsLoaded = True Then
lngID = DLookup("OwnerID", "tblInvoice", "InvoiceID = " _
& Form_frmModify.lstModify.Column(0))
ElseIf CurrentProject.AllForms("frmModifyInvoiceClient").IsLoaded =
True Then
lngID = DLookup("OwnerID", "tblInvoice", "InvoiceID = " _
& Form_frmModifyInvoiceClient.lstModify.value)
Else
Exit Sub
End If

strMail = Nz(DLookup("Email", "tblOwnerInfo", "OwnerID = " & lngID),
"")

If Not IsEmailOn Or Not IsOwnerWithEmail(lngID) Then
Exit Sub
End If

dtInvDate = Me.tbInvoiceDate
varInvNum = Me.tbInvoiceNumber
idHorse = Nz(Me.tbHorseID, 0)
If idHorse <> 0 Then
strHorse = Nz(DLookup("[HorseName]", "tblHorseInfo", "[HorseID]=" &
idHorse), "")
Else
strHorse = ""
End If

strBodyMsg = "Dear "
strBodyMsg = strBodyMsg & Nz(DLookup("[ClientTitle]", "tblOwnerInfo",
"[OwnerID]=" & lngID), " ") & " "
strBodyMsg = strBodyMsg & Nz(DLookup("[OwnerLastName]", "tblOwnerInfo",
"[OwnerID]=" & lngID), " Owner")
strBodyMsg = strBodyMsg & "," & Chr(10) & Chr(10) & Chr(13) _
& "Attached is your " & varInvNum & " Dated " & Format(dtInvDate,
"d-mmm-yyyy") _
& IIf(Len(strHorse) > 0, " for " & strHorse, "") & "." _
& eMailSignature("Best Regards", True) & Chr(10) & Chr(10) & Chr(13) _
& DownloadMessage("rtf")



If strMail = "Null" Or Len(strMail) = 0 Or _
DLookup("[MailFlag]", "tblAdminSetup") = False Then
Exit Sub
End If

DoCmd.SendObject acSendReport, Me.Name, acFormatRTF, strMail, , , "Your
Invoice", _
strBodyMsg, blEditMail


Exit Sub


If MsgBox("Do you want to send Email??", vbYesNo +
vbDefaultButton2) = vbYes Then

DoCmd.SendObject acSendReport, Me.Name, acFormatRTF,
strMail, , , _
"Your Invoice", strBodyMsg, True ' ** Change to "False"
later
End If

Exit Sub

Error_Handler:
Select Case Err.Number
Case 2501
Case 2487
Resume Next
Case Else
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description, , "Untrapped Error"

End Select

End Sub
 
N

noreply@noreply

In increase to this, Square-Enix has announced plans for unveiling the new Mythological Weapons through a idea titled "Summit 2008" which faculty be a variety of partnership between Square-Enix and the fan sites they cov infamy[/url:1twkqe7z]hump designated execute sites. More info can be launc (http://ugamegold.com/city-of-villains-infamy/:1twkqe7z).
 
N

noreply@noreply

Bump! thx !


It was the first day of school.

As the principal made his rounds, he heard a terrible
commotion coming from one of the classrooms.

He rushed in and spotted one boy, taller than the others, who seemed to be making the most noise.

He seized the lad, dragged him to the hall, and told him to wait there until he was excused.

Returning to the classroom, the principal restored order and lectured the class for half an hour about the importance of good behavior.

"Now," he said, "are there any questions?"

One girl stood up timidly. " Please sir," she asked, "May we have our teacher back?"
* Pet products[/url:3hut95dt], dog bed[/url:3hut95dt], pet supply[/url:3hut95dt], Dog Collar[/url:3hut95dt], Dog Clothes[/ur (http://www.lovelonglong.co (http://www.lovelonglong.co (http://www.lovelonglong.co (http://www.lovelonglong.co (http://www.lovelonglong.com:3hut95dt)95dt)95dt)95dt)95dt)95dt] *
 

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