View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Matthew Dyer Matthew Dyer is offline
external usenet poster
 
Posts: 178
Default posting this here cuz the outlook programing group is very inactive...

Thank you for the advice, but unfortunately only my first selected e-mail item is updating the flag.

There are attachments in every selected e-mail, but I only want to 'do stuff' when there is a PDF attachment. I was able to figure out how to save/print the pdf via shell, but adding categories/flagstatuses isn't happening on each e-mail.

On Tuesday, November 22, 2016 at 10:09:00 PM UTC-7, GS wrote:
Edit as follows to reset lngCount before looping the messages...

...
For Each objMsg In objSelection
Set objAttachments = objMsg.Attachments

lngCount = 0 'reset
lngCount = objAttachments.Count
If lngCount 0 Then

For i = lngCount To 1 Step -1
strFile = objAttachments.Item(i).FileName
If Right(strFile, 3) = "pdf" Then
strFile = strFolderpath & strFile
objAttachments.Item(i).SaveAsFile strFile
'use ShellExecute to open the file
'this may not work with zip extension if you use
Compressed folders ShellExecute 0, "print", strFile,
vbNullString, vbNullString, 0 objMsg.FlagStatus =
olFlagComplete

End If
Next
End If
Next

ExitSub:

Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub


--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion