Sub Salary_Slip_Email(fileName As String, ToEmail_ID As String, EMPL_NAME As String)
Dim Email_Obj As Object
Dim Email_Configuration As Object
Dim Mail_Configuration As Variant
Dim Email_Sub As String
Dim Message_From As String
Dim Message_To As String
Dim Email_Cc As String
Dim Email_Bcc As String
Dim Message_Body As String
Dim Message_Body_more1 As String
Dim Message_Body_more2 As String
Const cdoTimeout = 60 ' Timeout for SMTP in seconds
Call connect
If rst_Tab_Email_Setting.State <> adStateClosed Then
rst_Tab_Email_Setting.Close
Set rst_Tab_Email_Setting = Nothing
End If
query1 = "Select * from Tab_Email_Setting "
rst_Tab_Email_Setting.Open query1, Module1.con, 3, 3
If rst_Tab_Email_Setting.EOF = True And rst_Tab_Email_Setting.BOF = True Then
MsgBox "!! No Settings found, please enter new Settings !!", vbInformation, "Error "
Exit Sub
End If
Email_Sub = "Salary Slip - for the month of : " & Format(str, "MMM -YYYY") & " "
' Message_From = rst_Tab_Email_Setting!Send_User_ID
Message_From = "'HR-Department : Ambassador Sky Chef-Delhi' <" & rst_Tab_Email_Setting!Send_User_ID & ">" ' "
hrmasstdfk@ambassadorindia.com"
Modified = Now()
Message_To = ToEmail_ID
Message_Body = "Dear " & EMPL_NAME & "," & vbCrLf & _
"" & vbCrLf & _
" !! Good Day !! " & vbCrLf & _
" " & vbCrLf & _
" Please find attached Salary Slip for the month of " & Format(str, "MMM - YYYY") & " " & vbCrLf & _
" " & vbCrLf & _
" Kindly take a moment to review your payslip and ensure all details are accurate. Should you have any questions or concerns regarding your salary or any deductions, please do not hesitate to reach out to our HR department at
hrmdfk@ambassadorindia.com for clarification. " & vbCrLf & _
" " & vbCrLf & _
" Your hard work and dedication are greatly appreciated, and we are committed to ensuring that you receive accurate and timely compensation for your contributions to our organization. " & vbCrLf & _
" " & vbCrLf & _
" Thank you for your attention to this matter. " & vbCrLf & _
" " & vbCrLf & _
" Best regards, " & vbCrLf & _
" " & vbCrLf & _
" HR Department " & vbCrLf & _
" Company " & vbCrLf & _
" Address-2 " & vbCrLf & _
" Address-3 " & vbCrLf & _
" City " & vbCrLf & _
" " & vbCrLf & _
" " & vbCrLf
Message_Body_more1 = " Please Note :- " & vbCrLf & _
" This Salary Slip is password protected.The password is 4-character password. The date and month of your Date of Birth(DOB) ( as updated in our records) " & vbCrLf & _
" " & vbCrLf & _
" For instance, " & vbCrLf & _
" If your DOB(DD-MMM-YYYY) is 01-FEB-1991 then the password would be 0102 " & vbCrLf & _
" " & vbCrLf
Message_Body_more2 = " Please do not reply. This mail box is not monitored" & vbCrLf & _
" " & vbCrLf & _
" This is computer generated report. " & vbCrLf & _
" " & vbCrLf & _
" ****************** " & vbCrLf & _
" " & vbCrLf
Set Email_Obj = CreateObject("CDO.Message")
On Error GoTo Error_Handling
Set Email_Configuration = CreateObject("CDO.Configuration")
Email_Configuration.Load -1
Set Mail_Configuration = Email_Configuration.Fields
With Mail_Configuration
.Item("
http://schemas.microsoft.com/cdo/configuration/sendusing") = rst_Tab_Email_Setting!Send_Using
.Item("
http://schemas.microsoft.com/cdo/configuration/smtpserver") = rst_Tab_Email_Setting!SMTP_Server
.Item("
http://schemas.microsoft.com/cdo/configuration/smtpserverport") = rst_Tab_Email_Setting!SMTP_PORT
.Item("
http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = cdoTimeout
.Item("
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = rst_Tab_Email_Setting!SMTP_AUTH
.Item("
http://schemas.microsoft.com/cdo/configuration/sendusername") = rst_Tab_Email_Setting!Send_User_ID
.Item("
http://schemas.microsoft.com/cdo/configuration/sendpassword") = rst_Tab_Email_Setting!Password
.Item("
http://schemas.microsoft.com/cdo/configuration/smtpusessl") = rst_Tab_Email_Setting!SSL
.Update
End With
With Email_Obj
Set .Configuration = Email_Configuration
End With
With Email_Obj
.Subject = Email_Sub
.From = Message_From
.To = Message_To
' MsgBox fldrPath & "\" & fileName & ".pdf"
If i_individual_Clicked = 0 Then
.TextBody = Message_Body & Message_Body_more1 & Message_Body_more2
.AddAttachment (fldrPath & "\" & fileName & "_PROTECTED.pdf") ' Bulk email & Protected
ElseIf i_individual_Clicked = 1 Then
.TextBody = Message_Body & Message_Body_more2
.AddAttachment (fldrPath & "\" & fileName & ".pdf") ' Indvidual email & NOT Protected
End If
i_individual_Clicked = 0 ' bulk email & Protected
.Send
End With
rst_Tab_Email_Setting.Close
Set rst_Tab_Email_Setting = Nothing
Error_Handling:
If Err.Description <> "" Then MsgBox " Description :" & Err.Description & "; Error Number :" & Err.Number & " ; Source :" & Err.Source
End Sub
Show the code for attaching the file.
Have you walked your code and checked the path?