I've been using Cognos macros and scripts to run reports, save to excel or pdfs and then e-mail via lotus notes. However, I have several reports where I have to manually cut and paste a range of cells in excel into the body of the lotus notes email. Here is a sample of the code that I normally use. Does anyone have input on how I can add the copy paste needed into the body of this code?
Thanks in advance for any suggestions or leads.
sub WUAVAILABLE()
On Error GoTo Err_Main
' Declare Variables
Dim strFile As String
Dim strReportRunMth As String
Dim strErrorMsg as String
Dim strSendTo As String
Dim strSubject As String
Dim strBody As String
Dim strSaveIt As String
Dim ErrorCount As Integer
' Define Variables
' Full path and name of the output file
strFile = "\\sample path name\sample file name.xls"
' Error message to include
strErrorMsg = "An error was encountered in the WUAVAILABLE.sbh file."
' Recipient List
strSendTo = "sample email"
StrReportRunMth = Format(Date,"mm/dd/yyyy")
' Email Subject
strSubject = "Available Powers -- " &StrReportRunMth
' Email Body
strBody = "Please Reply with History from this e-mail to request additions or deletions to this distribution list."
' Save a copy of the e-mail (True or False)
strSaveit = "False"
' Begin Execution
ErrorCount = 0
Dim objLotusSes As Object ' Lotus Notes Session
Dim objLotusDbs As Object ' Lotus Notes Database
Dim objLotusDoc As Object ' Lotus Notes Document
Dim objLotusItem As Object ' Lotus Notes RichTextFile
Dim objAttachedFile As Object ' Attachment
Set objLotusSes = CreateObject("Notes.NotesSession")
Set objLotusDbs = objLotusSes.GETDATABASE("", "")
objLotusDbs.OPENMAIL
Set objLotusDoc = objLotusDbs.CREATEDOCUMENT()
Set objLotusItem = objLotusDoc.CREATERICHTEXTITEM("Attachment")
Set objAttachedFile = objLotusItem.EMBEDOBJECT(1454, "", strFile)
With objLotusDoc
.Subject = strSubject
.Body = strBody
.SaveMessageOnSend = strSaveIt
.Send False, strSendTo
End With
Exit_Main:
If ErrorCount = 0 Then
' MsgBox "WUAVAILABLE.sbh Successful!"
End If
Exit Sub
Err_Main:
MsgBox "Error # " & Err & " Line Nbr " & Erl & Chr$(13) & strErrorMsg
ErrorCount = 1
Resume Exit_Main
End Sub
Thanks in advance for any suggestions or leads.
sub WUAVAILABLE()
On Error GoTo Err_Main
' Declare Variables
Dim strFile As String
Dim strReportRunMth As String
Dim strErrorMsg as String
Dim strSendTo As String
Dim strSubject As String
Dim strBody As String
Dim strSaveIt As String
Dim ErrorCount As Integer
' Define Variables
' Full path and name of the output file
strFile = "\\sample path name\sample file name.xls"
' Error message to include
strErrorMsg = "An error was encountered in the WUAVAILABLE.sbh file."
' Recipient List
strSendTo = "sample email"
StrReportRunMth = Format(Date,"mm/dd/yyyy")
' Email Subject
strSubject = "Available Powers -- " &StrReportRunMth
' Email Body
strBody = "Please Reply with History from this e-mail to request additions or deletions to this distribution list."
' Save a copy of the e-mail (True or False)
strSaveit = "False"
' Begin Execution
ErrorCount = 0
Dim objLotusSes As Object ' Lotus Notes Session
Dim objLotusDbs As Object ' Lotus Notes Database
Dim objLotusDoc As Object ' Lotus Notes Document
Dim objLotusItem As Object ' Lotus Notes RichTextFile
Dim objAttachedFile As Object ' Attachment
Set objLotusSes = CreateObject("Notes.NotesSession")
Set objLotusDbs = objLotusSes.GETDATABASE("", "")
objLotusDbs.OPENMAIL
Set objLotusDoc = objLotusDbs.CREATEDOCUMENT()
Set objLotusItem = objLotusDoc.CREATERICHTEXTITEM("Attachment")
Set objAttachedFile = objLotusItem.EMBEDOBJECT(1454, "", strFile)
With objLotusDoc
.Subject = strSubject
.Body = strBody
.SaveMessageOnSend = strSaveIt
.Send False, strSendTo
End With
Exit_Main:
If ErrorCount = 0 Then
' MsgBox "WUAVAILABLE.sbh Successful!"
End If
Exit Sub
Err_Main:
MsgBox "Error # " & Err & " Line Nbr " & Erl & Chr$(13) & strErrorMsg
ErrorCount = 1
Resume Exit_Main
End Sub