Unable to send Salary Slip via Email (1 Viewer)

Local time
Yesterday, 20:23
Joined
Oct 7, 2016
Messages
43
While clicking on button "Email Salary Slip" as attached in *.mdb file we are getting the following error (Snapshot attached)


Description: The System cannot find the file specified.;
Error Number:-2147025894; Source :CDO.Message.1


Unable to send Salary Slip Email in PDF format with password Protected

For security reason Password not entered in
Table name --> Field
Tab_Email_Setting--> password

Kindly suggest.
 

Attachments

  • err.png
    err.png
    10 KB · Views: 73
  • Payslip.mdb
    Payslip.mdb
    1.2 MB · Views: 93
Show the code for attaching the file.

Have you walked your code and checked the path?
 
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?
 
Well I am getting that error on this line? Probably as I do not have that exe file. Do you?

How are we meant to even be able to test, if we do not have all the files required?

Code:
"C:\Program Files (x86)\gs\gs10.02.1\bin\gswin32c.exe" -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOwnerPassword=0711 -sUserPassword=0711 -sOutputFile="C:\PAYROLL\Payroll_report\Temp\ADMN0005_PROTECTED.PDF" "C:\PAYROLL\Payroll_report\Temp\ADMN0005.pdf"

Please use code tags when posting code. :(

Break your process down to small steps and test each one in turn.

And yes, I created the same folders for your hard coded paths. :(

Edit: Show the line the error occurs on, then the values of the variables.
 
Last edited:
Getting some fields error when trying via combo?

1711194540964.png


and get this after OKing to all

1711194491096.png
 

Users who are viewing this thread

Back
Top Bottom