Advertisement
Guest User

Untitled

a guest
Mar 27th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. Public Sub GenerateFinanceEmail()
  2. On Error GoTo ErrorHandle
  3.  
  4. Dim iMsg
  5. Set iMsg = CreateObject("CDO.Message")
  6. Dim iConf
  7. Set iConf = CreateObject("CDO.Configuration")
  8. Dim cc
  9.  
  10. 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
  11. cc = " email@email.com"
  12. 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
  13. cc = "email@email.com "
  14. 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
  15. cc = "email@email.com "
  16. 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
  17. cc = "email@email.com "
  18. Else
  19. cc = ""
  20. End If
  21.  
  22. With iConf.Fields
  23. .Item(cdoSendUsingMethod) = "2"
  24. .Item(cdoSMTPServer) = "192.168.1.3"
  25. .Item(cdoSMTPConnectionTimeout) = "20"
  26. .Item(cdoSMTPAuthenticate) = cdoBasic
  27. .Item(cdoSendUserName) = "web"
  28. .Item(cdoSendPassword) = "safety"
  29. .Update
  30. End With
  31.  
  32. Dim objFSO, strFolder, objFile, strFileName
  33. Set objFSO = CreateObject("Scripting.FileSystemObject")
  34. strFolder = "C:shoemobile_pospdf_files"
  35. strFileName = ""
  36. Dim zzfilename
  37.  
  38. zzfilename = Format$(Now, "mmddyyyy") & ".pdf"
  39.  
  40. With iMsg
  41. Set .Configuration = iConf
  42. .To = "email@email.com"
  43. .cc = cc
  44. .BCC = "email@email.com"
  45. .From = " email@email.com "
  46. .Subject = "POS Unloaded"
  47. .TextBody = "Laptop " & Form1.Data1.Recordset.Fields("laptopnum") & " has been unloaded."
  48. '.AddAttachment ("C:shoemobile_pospdf_filesSalesItemRecap_" & Format$(Now, "mmddyyyy") & ".pdf")
  49. '.AddAttachment ("C:shoemobile_pospdf_filesHourlyRecap_" & Format$(Now, "mmddyyyy") & ".pdf")
  50. For Each objFile In objFSO.GetFolder(strFolder).Files
  51. If Left(UCase(objFile.Name), 3) = "PRD" Then
  52. If Right(objFile.Name, 12) = zzfilename Then
  53. strFileName = objFile.Path
  54. .AddAttachment (strFileName)
  55. End If
  56. End If
  57. 'If strFileName <> "" Then
  58. '.AddAttachment (strFileName)
  59. 'End If
  60. Next objFile
  61. For Each objFile In objFSO.GetFolder(strFolder).Files
  62. If Left(objFile.Name, 9) = "TripRecap" Then
  63. If Right(objFile.Name, 12) = zzfilename Then
  64. strFileName = objFile.Path
  65. .AddAttachment (strFileName)
  66. End If
  67. End If
  68. 'If strFileName <> "" Then
  69. '.AddAttachment (strFileName)
  70. 'End If
  71. Next objFile
  72. For Each objFile In objFSO.GetFolder(strFolder).Files
  73. If Left(objFile.Name, 6) = "Hourly" Then
  74. If Right(objFile.Name, 12) = zzfilename Then
  75. strFileName = objFile.Path
  76. .AddAttachment (strFileName)
  77. End If
  78. End If
  79. 'If strFileName <> "" Then
  80. '.AddAttachment (strFileName)
  81. 'End If
  82. Next objFile
  83.  
  84. .send
  85. End With
  86.  
  87. DoEvents
  88.  
  89. ErrorHandle:
  90. 'Display error description
  91. MsgBox Err.Number, vbOKOnly, "ERROR"
  92. Resume Next
  93. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement