S
Steven M (to reply, remove the cola)
I recently wrote a macro that sends a list of all the attachments to
each of the mail items in the current folder, to a text file.
Now I'd like to be able to get a list of the attachments of just the
current email message. This macro is close, but I can't get it to
select the current message which is usually not the first one.
The help screens describe how to select the first item, or the last,
or items with a particular Subject, but not the "current" item.
The CurrentItem property sounds like it would be the right idea, but
it only works if I have opened a message.
Set myOLApp = CreateObject("Outlook.Application")
Set myInspector = myOLApp.ActiveInspector
Set thisItem = myOLApp.ActiveInspector.CurrentItem
How can I access the currently selected mail item when viewing Outlook
and not an open mail item?
Thanks.
=================
Sub SummarizeAttachmentsOneFile()
' This Outlook macro produces a list of the attachments to the current
message
Dim thisItem As Object
Dim Atmt As Attachment
' This line selects only item No. 1.
Set thisItem = Application.ActiveExplorer.CurrentFolder.Items(1)
' I want to select whichever mail item is highlighted, instead
Const SummaryFile = "C:\ATTACH\Temp.txt"
Open SummaryFile For Output As #2
If thisItem.Attachments.Count > 0 Then
Print #2, "From:", thisItem.SenderName
Print #2, "To:", thisItem.To
Print #2, "Sent:", thisItem.SentOn
Print #2, "Subject:", thisItem.Subject
Print #2, "Attachments: ("; thisItem.Attachments.Count; ")"
For Each Atmt In thisItem.Attachments
Print #2, , Atmt.FileName
Next Atmt
Print #2,
End If
Close
Shell ("C:\WINNT\system32\Notepad.exe " & SummaryFile)
End Sub
each of the mail items in the current folder, to a text file.
Now I'd like to be able to get a list of the attachments of just the
current email message. This macro is close, but I can't get it to
select the current message which is usually not the first one.
The help screens describe how to select the first item, or the last,
or items with a particular Subject, but not the "current" item.
The CurrentItem property sounds like it would be the right idea, but
it only works if I have opened a message.
Set myOLApp = CreateObject("Outlook.Application")
Set myInspector = myOLApp.ActiveInspector
Set thisItem = myOLApp.ActiveInspector.CurrentItem
How can I access the currently selected mail item when viewing Outlook
and not an open mail item?
Thanks.
=================
Sub SummarizeAttachmentsOneFile()
' This Outlook macro produces a list of the attachments to the current
message
Dim thisItem As Object
Dim Atmt As Attachment
' This line selects only item No. 1.
Set thisItem = Application.ActiveExplorer.CurrentFolder.Items(1)
' I want to select whichever mail item is highlighted, instead
Const SummaryFile = "C:\ATTACH\Temp.txt"
Open SummaryFile For Output As #2
If thisItem.Attachments.Count > 0 Then
Print #2, "From:", thisItem.SenderName
Print #2, "To:", thisItem.To
Print #2, "Sent:", thisItem.SentOn
Print #2, "Subject:", thisItem.Subject
Print #2, "Attachments: ("; thisItem.Attachments.Count; ")"
For Each Atmt In thisItem.Attachments
Print #2, , Atmt.FileName
Next Atmt
Print #2,
End If
Close
Shell ("C:\WINNT\system32\Notepad.exe " & SummaryFile)
End Sub