D
Dale
Hello all,
I have the following Outlook macro which has stopped working/is behaving
erratically between machines. It's always behaved perfectly before.
We have a client who sends 15 text files embedded in an email (not an
attachment). We have to save them out as text files to our network.
"If TypeOf obj Is Outlook.MailItem" seems to be the culprit.
ExportMailToTxt is just bypassed.
I have no idea why it would suddenly stop working. The only thing I can
come up with is something in the client's emails are playing havoc with the
macro.
Can anyone give me a clue to this puzzle?
Public Sub SAVESALES() 'LoopMailFolder()
Dim oSel As Outlook.Selection
Dim obj As Object
Dim cnt As Long
Dim SALEDate As String
Set oSel = Application.ActiveExplorer.Selection
cnt = oSel.Count
SALEDate = InputBox("What is today's date?")
If cnt = 15 Then
For i = 1 To cnt
Set obj = oSel(i)
If TypeOf obj Is Outlook.MailItem Then ' ///Item is not recognized
as a MailItem?
ExportMailToTxt obj, Chr$(96 + i), SALEDate ' ///This code is
bypassed
End If
Next
End If
Shell "d:\Program Files\UltraEdit\uedit32.exe Q:efiles\email\sale" &
SALEDate & "*.txt", vbNormalFocus
End Sub
Public Function ExportMailToTxt(oMail As Outlook.MailItem, _
sExt As String, sDate As String _
) As Boolean
On Error Resume Next
Dim sPath As String: sPath = "Q:efiles\email\" '"c:\"
Dim sName As String
sName = "SALE" & sDate _
& sExt & ".txt"
oMail.SaveAs sPath & sName, olTXT
ExportMailToTxt = (Err.Number = 0)
End Function
I have the following Outlook macro which has stopped working/is behaving
erratically between machines. It's always behaved perfectly before.
We have a client who sends 15 text files embedded in an email (not an
attachment). We have to save them out as text files to our network.
"If TypeOf obj Is Outlook.MailItem" seems to be the culprit.
ExportMailToTxt is just bypassed.
I have no idea why it would suddenly stop working. The only thing I can
come up with is something in the client's emails are playing havoc with the
macro.
Can anyone give me a clue to this puzzle?
Public Sub SAVESALES() 'LoopMailFolder()
Dim oSel As Outlook.Selection
Dim obj As Object
Dim cnt As Long
Dim SALEDate As String
Set oSel = Application.ActiveExplorer.Selection
cnt = oSel.Count
SALEDate = InputBox("What is today's date?")
If cnt = 15 Then
For i = 1 To cnt
Set obj = oSel(i)
If TypeOf obj Is Outlook.MailItem Then ' ///Item is not recognized
as a MailItem?
ExportMailToTxt obj, Chr$(96 + i), SALEDate ' ///This code is
bypassed
End If
Next
End If
Shell "d:\Program Files\UltraEdit\uedit32.exe Q:efiles\email\sale" &
SALEDate & "*.txt", vbNormalFocus
End Sub
Public Function ExportMailToTxt(oMail As Outlook.MailItem, _
sExt As String, sDate As String _
) As Boolean
On Error Resume Next
Dim sPath As String: sPath = "Q:efiles\email\" '"c:\"
Dim sName As String
sName = "SALE" & sDate _
& sExt & ".txt"
oMail.SaveAs sPath & sName, olTXT
ExportMailToTxt = (Err.Number = 0)
End Function