J
John
I'm stumped on this one. I've been all over the Internet looking for a
solution as to why this code refuses to save the sent e-mail in the Lotus
Notes Sent folder. This is mostly borrowed code, so kudos to the creator, but
I'm lost on how to get it to work for my purposes.
Thanks!
Sub SendEmail(EmailAddress As Variant)
Application.ScreenUpdating = False
'******************************************************************************
' Code Created 01/20/2004, MEMSr.
' This Module was created so the end-user can automatically save as an Excel
' file after report is refreshed. The Excel document is then attached to
Lotus
' Notes and an email is sent to their inbox for review. After review the
Excel
' document can be forward to additional recipents. Note: You must have Lotus
' Notes loaded on the local machine in order to run the macro. Also, you will
' need to have the Lotus Notes Library Reference added to the vb editor before
' the code will compile
'******************************************************************************
Dim EmailRow
Dim strBOdocument As String
Dim strBOUserDocsPath As String
Dim Family As String
Dim Div As String
Dim Counter As Boolean
Dim strAttachment As String
Dim DateTime As String
Dim SaveIt As Boolean
Counter = False
Dim domSession As New Domino.NotesSession
Dim domNotesDBMailFile As Domino.NotesDatabase
Dim domNotesDocumentMemo As Domino.NotesDocument
Dim domNotesRichText As Domino.NotesRichTextItem
'Set path for attachment
strBOUserDocsPath = "J:\OD Team Shared Drive\PM\PP&D\PP&D Tracking &
Reporting\HRBP"
DateTime = Sheets("Data").Range("B5")
strBOUserDocsPath = strBOUserDocsPath & "\" & DateTime & "\"
'Get Lotus Notes Password
If EmailPW = "" Then
EmailPW = InputBox("Please enter your Lotus Notes password:")
End If
domSession.Initialize (EmailPW)
For X = 1 To 100 Step 1
Set domNotesDBMailFile = domSession.GetDatabase("", "names.nsf")
Set domNotesDocumentMemo = domNotesDBMailFile.CreateDocument
Call domNotesDocumentMemo.AppendItemValue("Form", "Memo")
Call domNotesDocumentMemo.AppendItemValue("Importance", "1")
On Error GoTo Step1
'Loop until array is not blank
If EmailAddress(X) = "" Then GoTo Step1
'Check if Attachement Exsists
Call domNotesDocumentMemo.AppendItemValue("SendTo", EmailAddress(X))
'Find Attachement
LastRow = Sheets("Data").Range("H65536").End(xlUp).Row
With Sheets("Data").Range("H5", "H" & LastRow)
EmailFind = EmailAddress(X)
Set c = .Find(What:=EmailAddress(X), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=True)
If Not c Is Nothing Then
strBOdocument = Sheets("Data").Range("G" & c.Row)
strBOdocument = UCase(strBOdocument) & "_" & DateTime & ".xls"
Else
GoTo Step1
End If
End With
strAttachment = strBOUserDocsPath & strBOdocument
FileTest = File_Exists(strAttachment)
If FileTest = False Then GoTo Step1
'Create body of email
Call domNotesDocumentMemo.AppendItemValue("Subject", " ACT: Year-End
Performance Appraisals")
Set domNotesRichText = domNotesDocumentMemo.CreateRichTextItem("Body")
domNotesRichText.AppendText ("Attached is a report highlighting
Employees within your area(s) with incomplete Year-End Performance
Appraisals.")
domNotesRichText.AppendText (" This report indicates a paper-based,
Year-End Performance Appraisal has not been received by our HR Operations
team.")
domNotesRichText.AppendText (" If you have already submitted the
Year-End Performance Appraisal, please allow one to two weeks for them to be
validated and removed from this report.")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("The Year-End Performance Appraisal is a
critical element of Personal Performance & Development (PP&D) that supports
TD Bank's performance and development culture.")
domNotesRichText.AppendText (" In support of a consistent, positive
Employee experience our goal is 100% completion.")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Actions:")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Review the attached report and follow up
with Managers regarding incomplete Year-End Performance Appraisals")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Ensure Managers have all Year-End
Performance Appraisals submitted to you no later than January 31st")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Ensure you have all Year-End Performance
Appraisals submitted to Centralized Processing no later than February 5th")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Contact Grace Parascando at 856-533-7256,
with any questions concerning this report")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Contact Christopher Leady at 856-533-7227,
with any question regarding PP&D")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Thank you for your continued support!")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
Label2:
On Error GoTo 0
'Attach file
Call domNotesRichText.EmbedObject(EMBED_ATTACHMENT, "", strAttachment, "")
'Send E-mail
SaveIt = True
With domNotesDocumentMemo
.SaveMessageOnSend = True
' .PostedDate = Now()
.Send (True)
End With
Step1:
Next X
Application.ScreenUpdating = True
End Sub
solution as to why this code refuses to save the sent e-mail in the Lotus
Notes Sent folder. This is mostly borrowed code, so kudos to the creator, but
I'm lost on how to get it to work for my purposes.
Thanks!
Sub SendEmail(EmailAddress As Variant)
Application.ScreenUpdating = False
'******************************************************************************
' Code Created 01/20/2004, MEMSr.
' This Module was created so the end-user can automatically save as an Excel
' file after report is refreshed. The Excel document is then attached to
Lotus
' Notes and an email is sent to their inbox for review. After review the
Excel
' document can be forward to additional recipents. Note: You must have Lotus
' Notes loaded on the local machine in order to run the macro. Also, you will
' need to have the Lotus Notes Library Reference added to the vb editor before
' the code will compile
'******************************************************************************
Dim EmailRow
Dim strBOdocument As String
Dim strBOUserDocsPath As String
Dim Family As String
Dim Div As String
Dim Counter As Boolean
Dim strAttachment As String
Dim DateTime As String
Dim SaveIt As Boolean
Counter = False
Dim domSession As New Domino.NotesSession
Dim domNotesDBMailFile As Domino.NotesDatabase
Dim domNotesDocumentMemo As Domino.NotesDocument
Dim domNotesRichText As Domino.NotesRichTextItem
'Set path for attachment
strBOUserDocsPath = "J:\OD Team Shared Drive\PM\PP&D\PP&D Tracking &
Reporting\HRBP"
DateTime = Sheets("Data").Range("B5")
strBOUserDocsPath = strBOUserDocsPath & "\" & DateTime & "\"
'Get Lotus Notes Password
If EmailPW = "" Then
EmailPW = InputBox("Please enter your Lotus Notes password:")
End If
domSession.Initialize (EmailPW)
For X = 1 To 100 Step 1
Set domNotesDBMailFile = domSession.GetDatabase("", "names.nsf")
Set domNotesDocumentMemo = domNotesDBMailFile.CreateDocument
Call domNotesDocumentMemo.AppendItemValue("Form", "Memo")
Call domNotesDocumentMemo.AppendItemValue("Importance", "1")
On Error GoTo Step1
'Loop until array is not blank
If EmailAddress(X) = "" Then GoTo Step1
'Check if Attachement Exsists
Call domNotesDocumentMemo.AppendItemValue("SendTo", EmailAddress(X))
'Find Attachement
LastRow = Sheets("Data").Range("H65536").End(xlUp).Row
With Sheets("Data").Range("H5", "H" & LastRow)
EmailFind = EmailAddress(X)
Set c = .Find(What:=EmailAddress(X), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=True)
If Not c Is Nothing Then
strBOdocument = Sheets("Data").Range("G" & c.Row)
strBOdocument = UCase(strBOdocument) & "_" & DateTime & ".xls"
Else
GoTo Step1
End If
End With
strAttachment = strBOUserDocsPath & strBOdocument
FileTest = File_Exists(strAttachment)
If FileTest = False Then GoTo Step1
'Create body of email
Call domNotesDocumentMemo.AppendItemValue("Subject", " ACT: Year-End
Performance Appraisals")
Set domNotesRichText = domNotesDocumentMemo.CreateRichTextItem("Body")
domNotesRichText.AppendText ("Attached is a report highlighting
Employees within your area(s) with incomplete Year-End Performance
Appraisals.")
domNotesRichText.AppendText (" This report indicates a paper-based,
Year-End Performance Appraisal has not been received by our HR Operations
team.")
domNotesRichText.AppendText (" If you have already submitted the
Year-End Performance Appraisal, please allow one to two weeks for them to be
validated and removed from this report.")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("The Year-End Performance Appraisal is a
critical element of Personal Performance & Development (PP&D) that supports
TD Bank's performance and development culture.")
domNotesRichText.AppendText (" In support of a consistent, positive
Employee experience our goal is 100% completion.")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Actions:")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Review the attached report and follow up
with Managers regarding incomplete Year-End Performance Appraisals")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Ensure Managers have all Year-End
Performance Appraisals submitted to you no later than January 31st")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Ensure you have all Year-End Performance
Appraisals submitted to Centralized Processing no later than February 5th")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Contact Grace Parascando at 856-533-7256,
with any questions concerning this report")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Contact Christopher Leady at 856-533-7227,
with any question regarding PP&D")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AppendText ("Thank you for your continued support!")
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
domNotesRichText.AddNewLine
Label2:
On Error GoTo 0
'Attach file
Call domNotesRichText.EmbedObject(EMBED_ATTACHMENT, "", strAttachment, "")
'Send E-mail
SaveIt = True
With domNotesDocumentMemo
.SaveMessageOnSend = True
' .PostedDate = Now()
.Send (True)
End With
Step1:
Next X
Application.ScreenUpdating = True
End Sub