Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub GenerateFinanceEmail()
- On Error GoTo ErrorHandle
- Dim iMsg
- Set iMsg = CreateObject("CDO.Message")
- Dim iConf
- Set iConf = CreateObject("CDO.Configuration")
- Dim cc
- If Form1.Adodc1.Recordset.Fields("whse").Value = "02" Or Form1.Adodc1.Recordset.Fields("whse").Value = "04" Or Form1.Adodc1.Recordset.Fields("whse").Value = "26" Or Form1.Adodc1.Recordset.Fields("whse").Value = "28" Or Form1.Adodc1.Recordset.Fields("whse").Value = "40" Or Form1.Adodc1.Recordset.Fields("whse").Value = "45" Or Form1.Adodc1.Recordset.Fields("whse").Value = "50" Or Form1.Adodc1.Recordset.Fields("whse").Value = "420" Then
- cc = " email@email.com"
- ElseIf Form1.Adodc1.Recordset.Fields("whse").Value = "35" Or Form1.Adodc1.Recordset.Fields("whse").Value = "67" Or Form1.Adodc1.Recordset.Fields("whse").Value = "68" Or Form1.Adodc1.Recordset.Fields("whse").Value = "310" Or Form1.Adodc1.Recordset.Fields("whse").Value = "311" Or Form1.Adodc1.Recordset.Fields("whse").Value = "702" Then
- cc = "email@email.com "
- ElseIf Form1.Adodc1.Recordset.Fields("whse").Value = "55" Or Form1.Adodc1.Recordset.Fields("whse").Value = "91" Or Form1.Adodc1.Recordset.Fields("whse").Value = "92" Or Form1.Adodc1.Recordset.Fields("whse").Value = "93" Or Form1.Adodc1.Recordset.Fields("whse").Value = "94" Or Form1.Adodc1.Recordset.Fields("whse").Value = "501" Then
- cc = "email@email.com "
- ElseIf Form1.Adodc1.Recordset.Fields("whse").Value = "79" Or Form1.Adodc1.Recordset.Fields("whse").Value = "82" Or Form1.Adodc1.Recordset.Fields("whse").Value = "84" Or Form1.Adodc1.Recordset.Fields("whse").Value = "85" Or Form1.Adodc1.Recordset.Fields("whse").Value = "300" Or Form1.Adodc1.Recordset.Fields("whse").Value = "301" Or Form1.Adodc1.Recordset.Fields("whse").Value = "800" Then
- cc = "email@email.com "
- Else
- cc = ""
- End If
- With iConf.Fields
- .Item(cdoSendUsingMethod) = "2"
- .Item(cdoSMTPServer) = "192.168.1.3"
- .Item(cdoSMTPConnectionTimeout) = "20"
- .Item(cdoSMTPAuthenticate) = cdoBasic
- .Item(cdoSendUserName) = "web"
- .Item(cdoSendPassword) = "safety"
- .Update
- End With
- Dim objFSO, strFolder, objFile, strFileName
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- strFolder = "C:shoemobile_pospdf_files"
- strFileName = ""
- Dim zzfilename
- zzfilename = Format$(Now, "mmddyyyy") & ".pdf"
- With iMsg
- Set .Configuration = iConf
- .To = "email@email.com"
- .cc = cc
- .BCC = "email@email.com"
- .From = " email@email.com "
- .Subject = "POS Unloaded"
- .TextBody = "Laptop " & Form1.Data1.Recordset.Fields("laptopnum") & " has been unloaded."
- '.AddAttachment ("C:shoemobile_pospdf_filesSalesItemRecap_" & Format$(Now, "mmddyyyy") & ".pdf")
- '.AddAttachment ("C:shoemobile_pospdf_filesHourlyRecap_" & Format$(Now, "mmddyyyy") & ".pdf")
- For Each objFile In objFSO.GetFolder(strFolder).Files
- If Left(UCase(objFile.Name), 3) = "PRD" Then
- If Right(objFile.Name, 12) = zzfilename Then
- strFileName = objFile.Path
- .AddAttachment (strFileName)
- End If
- End If
- 'If strFileName <> "" Then
- '.AddAttachment (strFileName)
- 'End If
- Next objFile
- For Each objFile In objFSO.GetFolder(strFolder).Files
- If Left(objFile.Name, 9) = "TripRecap" Then
- If Right(objFile.Name, 12) = zzfilename Then
- strFileName = objFile.Path
- .AddAttachment (strFileName)
- End If
- End If
- 'If strFileName <> "" Then
- '.AddAttachment (strFileName)
- 'End If
- Next objFile
- For Each objFile In objFSO.GetFolder(strFolder).Files
- If Left(objFile.Name, 6) = "Hourly" Then
- If Right(objFile.Name, 12) = zzfilename Then
- strFileName = objFile.Path
- .AddAttachment (strFileName)
- End If
- End If
- 'If strFileName <> "" Then
- '.AddAttachment (strFileName)
- 'End If
- Next objFile
- .send
- End With
- DoEvents
- ErrorHandle:
- 'Display error description
- MsgBox Err.Number, vbOKOnly, "ERROR"
- Resume Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement