Hi All,
just a quick one to ask for assistance. I know, my questions are never a quick one
When submitting a document to be mailed, the system requires to enter the gmail account password
Now for some reason the users does not enter the password, they either click on ok or cancel or on the X to close.
The macro then runs but no mail is sent.
Ok should not be active when the password has not been entered.
And when canceled, the macro should not run
Please could you advise on where the changes should be made as I am not sure
Also, if the password is not entered or incorrect, the macro should not run.
error of incorrect password should be shown then to re enter password
just a quick one to ask for assistance. I know, my questions are never a quick one
When submitting a document to be mailed, the system requires to enter the gmail account password
Now for some reason the users does not enter the password, they either click on ok or cancel or on the X to close.
The macro then runs but no mail is sent.
Ok should not be active when the password has not been entered.
And when canceled, the macro should not run
Please could you advise on where the changes should be made as I am not sure
Also, if the password is not entered or incorrect, the macro should not run.
error of incorrect password should be shown then to re enter password
Option Compare Database
Option Explicit
Dim strFilename As String, strMsg As String
Dim aProjectLeaderMail As String
Dim aProductionPlannerMail As String
Dim aCurrentUserMail As String
Dim scc As String
Dim vRecipientList As String
Dim vRecipientListFrom As String
Private Sub Excecute_Click()
Dim SQL As String
Dim WPassStr As String
Dim sSQL As String
'Enter Password
If Nz(DLookup("[WPass]", "[GMailSettingsQry]")) = "" Then
Dim Message As String, Title As String, Default As String
Message = "Enter Windows Password"
Title = "Enter Parameters"
'WPassStr = InputBox(Message, Title)
WPassStr = InputBoxDK(Message, Title) '(* Password)
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE GMailSettingsQry SET WPass =""" & WPassStr & """"
End If
Dim rs As Recordset
Dim vMsg As String
Dim vSubject As String
Dim vReportPDF As String
Set rs = CurrentDb.OpenRecordset("SELECT * FROM EmailTBLQry_NewDaw; ")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do
'Set To Recipient
If Not IsNull(rs!To) Then vRecipientList = vRecipientList & rs("To") & ","
If Not IsNull(rs!To) Then vRecipientListFrom = vRecipientListFrom & rs("CurrentUserMail")
'Set CC Recipient
If Not IsNull(rs!ProjectLeaderMail) And rs!ProjectLeaderMail <> "N/A" Then aProjectLeaderMail = aProjectLeaderMail & rs("ProjectLeaderMail") & ","
If Not IsNull(rs!ProductionPlannerMail) And rs!ProductionPlannerMail <> "N/A" Then aProductionPlannerMail = aProductionPlannerMail & rs("ProductionPlannerMail") & ","
If Not IsNull(rs!CurrentUserMail) And rs!CurrentUserMail <> "N/A" Then aCurrentUserMail = aCurrentUserMail & rs("CurrentUserMail") & ","
'It send mail, I need Production Planner, Project leader and Current user mail (If not the same as production planner)
If aProjectLeaderMail <> aProductionPlannerMail Then
scc = scc & aProjectLeaderMail & "," & aProductionPlannerMail & ","
If aCurrentUserMail <> aProductionPlannerMail And aCurrentUserMail <> aProjectLeaderMail Then
scc = scc & "," & aCurrentUserMail & ","
End If
Else
scc = scc & aProjectLeaderMail & ","
If aCurrentUserMail <> aProductionPlannerMail Then
scc = scc & "," & aCurrentUserMail & ","
End If
End If
rs.MoveNext
Loop Until rs.EOF
'vSubject = "New DAW Sheet Listing - Registration: " & " " & rs("Registration")
vSubject = "New DAW Sheet Listing - Registration: " & " " & DLookup("[Registration]", "[EmailTblQry_NewDaw]")
vReportPDF = CurrentProject.Path & "\" & "DAW Sheet.pdf"
'<<<<<<<<<<<<<<<<<<<<export the report as PDF>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DoCmd.OutputTo acReport, "DAW Sheet", acFormatPDF, vReportPDF
'<<<<<<<<<<<<<<<<<<<<export the report as PDF>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'<<<<<<<<<<<<<<<<<<call Colin's sub to email report as attachment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
SendEMailCDO vRecipientList, scc, vSubject, vMsg, "", vReportPDF
'<<<<<<<<<<<<<<<<<<call Colin's sub to email report as attachment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'MsgBox ("Report successfully eMailed!")
'Debug.Print aProjectLeaderMail, aProductionPlannerMail, aCurrentUserMail
'Debug.Print sCC
'Debug.Print vRecipientList
'Debug.Print aCurrentUserMail
Else
MsgBox "No contacts."
End If
DoCmd.RunMacro "New DAW Email List"
DoCmd.SetWarnings True
End Sub