D
Dale
I have the following:
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 obj.Class = olMail Then
ExportMailToTxt obj, Chr$(96 + i), SALEDate
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 Object, _
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 ' errs here when On Error statment is
disabled.
ExportMailToTxt = (Err.Number = 0)
End Function
This code works fine on my computer but works intermittently if at all on
the computer it must work on. I get the a run-time error when the "On
Error" statement in the Function is disabled. The error says "method
'SaveAs' of object 'MailItem' failed".
One thought is the version of outlook. Both computers have Outlook 2003 SP2
althought the other computer seems to be somewhat more up-to-date. It is
version 11.8010.8036. My computer is version 11.8010..6568. Possibly an
update broke something?
Can anyone explain what's happening?
Regards
Dale
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 obj.Class = olMail Then
ExportMailToTxt obj, Chr$(96 + i), SALEDate
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 Object, _
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 ' errs here when On Error statment is
disabled.
ExportMailToTxt = (Err.Number = 0)
End Function
This code works fine on my computer but works intermittently if at all on
the computer it must work on. I get the a run-time error when the "On
Error" statement in the Function is disabled. The error says "method
'SaveAs' of object 'MailItem' failed".
One thought is the version of outlook. Both computers have Outlook 2003 SP2
althought the other computer seems to be somewhat more up-to-date. It is
version 11.8010.8036. My computer is version 11.8010..6568. Possibly an
update broke something?
Can anyone explain what's happening?
Regards
Dale