A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Inbox Rule: Auto Print Attachments



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old January 19th 07, 11:11 PM posted to microsoft.public.outlook.program_addins
Alan in NJ
external usenet poster
 
Posts: 4
Default Inbox Rule: Auto Print Attachments

The following properly prints the attachments to a selected email in the
Inbox, but am trying to use it as a script in a Rule that only runs for a
particular sender. I believe the problem that I am not "selecting" the
just-received email that triggers the rule. Any help would be appreciated

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub PrintAttachment(Item As Outlook.MailItem)



Dim myItems, myItem, myAttachments, myAttachment As Object
Dim myOrt As String
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim strFile As String

'Set destination folder
myOrt = "C:\program files\microsoft office\"


On Error Resume Next
'work on selected items
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
'for all items do...
For Each myItem In myOlSel
'point on attachments
Set myAttachments = myItem.Attachments
If myAttachments.Count 0 Then
'for all attachments do...
For i = 1 To myAttachments.Count
'save them to destination
myAttachments(i).SaveAsFile myOrt &
myAttachments(i).DisplayName
strFile = myOrt & myAttachments(i).DisplayName

ShellExecute 0&, "print", strFile, 0&, 0&, 0&
NextOne:

Next i

myItem.Save

End If
Next
Set myItems = Nothing
Set myItem = Nothing
Set myAttachments = Nothing
Set myAttachment = Nothing
Set myOlApp = Nothing
Set myOlExp = Nothing
Set myOlSel = Nothing



End Sub




AlanNJ



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Auto Rule (URGENT) Outlook - General Queries 2 August 9th 06 12:59 PM
Outlook Auto Rule (URGENT) Outlook - Installation 2 August 9th 06 12:59 PM
Outlook Auto Rule (URGENT) Outlook and VBA 2 August 9th 06 12:59 PM
create a rule to auto delete attachments on a meeting requests? V-@pearson Outlook - Calandaring 1 June 22nd 06 08:59 PM
Auto reply rule within Outlook 2003 WetBehindEars Outlook - Installation 1 February 15th 06 07:59 PM


All times are GMT +1. The time now is 12:41 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.