I have a function that allows me to add to reports to an email as attachments. However, the report automatically sends. I really want the code to attach the reports to an email but not send it so the user can enter the addresses, as it will vary by Region. Can someone help me with this?
Public Function BuilderEmail()
Dim doc As Object 'Lotus NOtes Document
Dim rtitem As Object '
Dim Body2 As Object
Dim Body3 As Object
Dim ws As Object 'Lotus Notes Workspace
Dim oSess As Object 'Lotus Notes Session
Dim oDB As Object 'Lotus Notes Database
Dim x As Integer 'Counter
Dim strFileName As String
Dim strFileName2 As String
Dim strTo As String
Dim strSubject As String
Dim strBody As String
Dim ctr As Integer
strSubject = "Scheduled and Unscheduled Units"
strBody = "Attached is the upcoming install schedule for active orders. A list of units currently unscheduled is also attached for your convenience. Please review and notify your customer service representative of any discrepancies."
DoCmd.OutputTo acOutputReport, "rpLotSchedulebyBuildertoInstall", acFormatPDF, "C:\Installs.pdf"
DoCmd.OutputTo acOutputReport, "rpLotUnSchedulebyBuilder", acFormatPDF, "C:\Unscheduled.pdf"
DoCmd.Close acForm, "Delivery Reports"
Set oSess = CreateObject("Notes.NotesSession")
'access the logged on users mailbox
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
'create a new document as add text
Set doc = oDB.CREATEDOCUMENT
Set rtitem = doc.CREATERICHTEXTITEM("Body")
doc.sendto = "Richmond"
doc.CopyTo = ""
doc.BlindCopyTo = "brenenger@masterbrandcabinets.com"
doc.Subject = strSubject
doc.Body = strBody & vbCrLf & vbCrLf
strFileName = "C:\Installs.pdf"
strFileName2 = "C:\Unscheduled.pdf"
'attach files
If strFileName <> "" Then
Set Body2 = rtitem.EmbedObject(1454, "", strFileName)
End If
If strFileName2 <> "" Then
Set Body3 = rtitem.EmbedObject(1454, "", strFileName2)
End If
doc.SAVEMESSAGEONSEND = True
doc.SEND False
BuilderEmail = True
Kill ("C:\Unscheduled.pdf")
Kill ("C:\Installs.pdf")
End Function
Public Function BuilderEmail()
Dim doc As Object 'Lotus NOtes Document
Dim rtitem As Object '
Dim Body2 As Object
Dim Body3 As Object
Dim ws As Object 'Lotus Notes Workspace
Dim oSess As Object 'Lotus Notes Session
Dim oDB As Object 'Lotus Notes Database
Dim x As Integer 'Counter
Dim strFileName As String
Dim strFileName2 As String
Dim strTo As String
Dim strSubject As String
Dim strBody As String
Dim ctr As Integer
strSubject = "Scheduled and Unscheduled Units"
strBody = "Attached is the upcoming install schedule for active orders. A list of units currently unscheduled is also attached for your convenience. Please review and notify your customer service representative of any discrepancies."
DoCmd.OutputTo acOutputReport, "rpLotSchedulebyBuildertoInstall", acFormatPDF, "C:\Installs.pdf"
DoCmd.OutputTo acOutputReport, "rpLotUnSchedulebyBuilder", acFormatPDF, "C:\Unscheduled.pdf"
DoCmd.Close acForm, "Delivery Reports"
Set oSess = CreateObject("Notes.NotesSession")
'access the logged on users mailbox
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
'create a new document as add text
Set doc = oDB.CREATEDOCUMENT
Set rtitem = doc.CREATERICHTEXTITEM("Body")
doc.sendto = "Richmond"
doc.CopyTo = ""
doc.BlindCopyTo = "brenenger@masterbrandcabinets.com"
doc.Subject = strSubject
doc.Body = strBody & vbCrLf & vbCrLf
strFileName = "C:\Installs.pdf"
strFileName2 = "C:\Unscheduled.pdf"
'attach files
If strFileName <> "" Then
Set Body2 = rtitem.EmbedObject(1454, "", strFileName)
End If
If strFileName2 <> "" Then
Set Body3 = rtitem.EmbedObject(1454, "", strFileName2)
End If
doc.SAVEMESSAGEONSEND = True
doc.SEND False
BuilderEmail = True
Kill ("C:\Unscheduled.pdf")
Kill ("C:\Installs.pdf")
End Function