Option Explicit
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Declaration
Dim strSubject As String
Dim strSubjectA As String
Dim strPartN As String
Dim strShipDT As String
Dim strPO As String
Dim strDesc As String
Dim strPiec As String
Dim myOrtK As String
Dim myOrtG As String
Dim strA As String
Dim strRev As String
Dim Filename As String
Dim Prompt$
Dim myOlApp As New Outlook.Application
'Destination folder
myOrtK = "R:\CERTS\KOHLER"
myOrtG = "R:\CERTS\GENERAC"
On Error Resume Next
strSubject = Item.Subject
strA = Item.Subject
If strSubject = "KECCERT" Then
Prompt$ = "Do you want to send this Cert to Kohler?"
If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Attachment") = vbNo Then
Cancel = True
Exit Sub
End If
strPartN = InputBox("Part Number", "Please insert Part number")
strShipDT = InputBox("Ship Date", "Please insert Ship date")
strPO = InputBox("P.O", "Please insert P.O number")
strRev = InputBox("Revision", "Please insert Revision")
Set Item = Outlook.Application.ActiveInspector.currentItem
Item.Subject = "PN_" + strPartN + "_SD_" + strShipDT + "_PO_" + strPO
strSubjectA = strA + strShipDT + strPartN + strRev
ElseIf strSubject = "GNCCERT" Then
Prompt$ = "Do you want to send this Cert to Generac?"
If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Attachment") = vbNo Then Cancel = True
strPartN = InputBox("Part Number", "Please insert Part number")
strDesc = InputBox("Part Description", "Please insert Part Description")
strPO = InputBox("P.O", "Please insert P.O number")
strPiec = InputBox("Number of Pieces", "Please insert number of Pieces")
strShipDT = InputBox("Ship Date", "Please insert Ship date")
strRev = InputBox("Revision", "Please insert Revision")
Set Item = Outlook.Application.ActiveInspector.currentItem
Item.Subject = strPartN + "," + strDesc + "," + strPO + "," + strPiec + "," + strShipDT
strSubjectA = strA + strShipDT + strPartN + strRev
End If
Prompt$ = "Do you want to send this Cert With this subject line?" + Item.Subject
If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Attachment") = vbNo Then
Cancel = True
Exit Sub
End If
Set objApp = CreateObject("Outlook.Application")
Set objEXP = objApp.ActiveExplorer
Set objSel = objEXP.Selection
Set SRC1 = objSel.Item(1)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
Dim PATH As String
PATH = "C:\test\"
For Each ITEM2 In objSel
Set myAttachments = ITEM2.Attachments
If myAttachments.Count > 0 Then
For i = 1 To myAttachments.Count
myAttachments(i).SaveAsFile PATH & _
myAttachments(i).DisplayName
Next
End If
Next
'free variables
End Sub