H
Henry Stockbridge
Hi,
I have created a rule for incoming messages with attachments that
writes information to a text file about the date, sender, and
filename. The script runs successfully if the email message has one
(1) attachment, but throws an error ('Object variable or With block
variable not set) if the message contains more than one attachment.
======================
Sub Coordinator_Emails_2(item As Outlook.MailItem)
Const ForAppending = 8
Dim fso
Dim f1
Dim ts
Dim i As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.GetFile("c:\ReportingLog.txt")
Set ts = f1.OpenAsTextStream(ForAppending, True)
For i = 1 To item.Attachments.Count '- 1
'MsgBox item.Attachments(i).FileName
ts.Write Format(item.SentOn, "Short Date") & vbTab & item.Subject
& vbTab & item.To & vbTab & item.Attachments(i)
ts.writeblanklines (1)
ts.Close
Next i
Set ts = nothing
Set f1 = nothing
set fso = nothing
End Sub
======================
Any help you can lend would be appreciated.
Henry
I have created a rule for incoming messages with attachments that
writes information to a text file about the date, sender, and
filename. The script runs successfully if the email message has one
(1) attachment, but throws an error ('Object variable or With block
variable not set) if the message contains more than one attachment.
======================
Sub Coordinator_Emails_2(item As Outlook.MailItem)
Const ForAppending = 8
Dim fso
Dim f1
Dim ts
Dim i As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.GetFile("c:\ReportingLog.txt")
Set ts = f1.OpenAsTextStream(ForAppending, True)
For i = 1 To item.Attachments.Count '- 1
'MsgBox item.Attachments(i).FileName
ts.Write Format(item.SentOn, "Short Date") & vbTab & item.Subject
& vbTab & item.To & vbTab & item.Attachments(i)
ts.writeblanklines (1)
ts.Close
Next i
Set ts = nothing
Set f1 = nothing
set fso = nothing
End Sub
======================
Any help you can lend would be appreciated.
Henry