Private Sub cmdEmailReport_Click() Dim strPrevMnth As String Dim strCurrMnth As String Dim strPathName As String Dim strRptName As String Dim strEMRecipients As String Dim strEMCCRecipients As String Dim strEMSubject As String Dim strEMBody As String Dim strEMAttach As String 'Dates for Report Name strPrevMnth = Format(DateSerial(Year(Date), Month(Now), 0), "MMM DD, YYYY") strCurrMnth = Format(Now() - 1, "MMM DD, YYYY") 'Email Recipients strEMRecipients = "firstname.lastname@example.org" strEMCCRecipients = "email@example.com" 'Email Subject strEMSubject = "Attorney Monthly Hours Report" 'Email Body strEMBody = "Please find attached the Attorney Monthly Hours Report as of 3/8/2016." 'Path and Report Name 'strPathName = "H:\NRTEcho\ACTIVE\gdunn59\Atty Monthly Hours Report (WIP - Automate Email)\" strPathName = "H:\NRTEcho\ACTIVE\gdunn59\" strRptName = "Attorney Fiscal YTD Hrs Report Through " & strPrevMnth & " as of " & strCurrMnth & " - Full" & ".pdf" 'strRptName = "Attorney Fiscal YTD Hrs Report Through " & strPrevMnth & " as of " & strCurrMnth & " - Full" 'Report strEMAttach = strPathName & strRptName 'Send Report via Email Set Mail_Object = CreateObject("Outlook.Application") Set Mail_Single = Mail_Object.CreateItem(0) With Mail_Single .Subject = strEMSubject .To = strEMRecipients .cc = strEMCCRecipients .BCC = "" .Body = strEMBody .Attachments.Add (strEMAttach) .send End With debugs: 'If Err.Description "" Then MsgBox Err.Description End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.