OTWarrior
12-06-2010, 06:14 AM
We have to save emails to the folder of each client (identified by a unique 9 digit number), and I have the following code that works when applicable:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim MItem As Object
Dim nID As String
Dim Folderpath As String
Dim subject As String
On Error GoTo err1
Set MItem = ActiveInspector.CurrentItem
If FindnIDNumber(MItem.subject) = 0 Then Exit Sub
nID = FindnIDNumber(MItem.subject)
subject = Replace(MItem.subject, "/", "-", 1)
subject = Replace(subject, "|", "-", 1)
subject = Replace(subject, ":", "-", 1)
ActiveInspector.WindowState = olMinimized
DEPT = "Case" ' this has been changed to for this posting as this is company information.
Folderpath = MakeFolder(nID )
Folderpath = MakeFolder(nID & DEPT)
If nID <> "" Then
Folderpath = Folderpath & subject & ".msg"
MItem.SaveAs Folderpath, olMSG
MsgBox "Email saved: " & Folderpath, vbInformation
End If
Exit Sub
err1:
End Sub
This saves fine, but it does so before the email is sent. If you open up the file it has saved it has "this item has not been sent" on the menu bar. I have tried using:
item.sent = true
but this ends the procedure.
Is there a way of changing this to be the item as it is sent, not before it is sent?
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim MItem As Object
Dim nID As String
Dim Folderpath As String
Dim subject As String
On Error GoTo err1
Set MItem = ActiveInspector.CurrentItem
If FindnIDNumber(MItem.subject) = 0 Then Exit Sub
nID = FindnIDNumber(MItem.subject)
subject = Replace(MItem.subject, "/", "-", 1)
subject = Replace(subject, "|", "-", 1)
subject = Replace(subject, ":", "-", 1)
ActiveInspector.WindowState = olMinimized
DEPT = "Case" ' this has been changed to for this posting as this is company information.
Folderpath = MakeFolder(nID )
Folderpath = MakeFolder(nID & DEPT)
If nID <> "" Then
Folderpath = Folderpath & subject & ".msg"
MItem.SaveAs Folderpath, olMSG
MsgBox "Email saved: " & Folderpath, vbInformation
End If
Exit Sub
err1:
End Sub
This saves fine, but it does so before the email is sent. If you open up the file it has saved it has "this item has not been sent" on the menu bar. I have tried using:
item.sent = true
but this ends the procedure.
Is there a way of changing this to be the item as it is sent, not before it is sent?