I am aware that I could accomplish Items 2 & 3 using a simple rule in
Outlook. From what I have discovered I need to use VB to try and get 1 done.
Any ideas on what I can do. From what I can tell there is no Print method
for the Attachment property.
(I am going to just guess something here, that maube I need to open then Tif
file and use other types og Objects to do the prinitng)
I do have some VB scripting experience with Access. But I have never
scripted in Outlook.
I have started a script, just to try and play around, its in the Module that
is with the "This Outlook Session". Another thing I would need help with, is
how do I get it to run automatically when New Emails arrive. I see How I can
run the Macro manually, but not automatically.
Feel Free to speak in "Medium" level language.
Thanks,
Yoni
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Yonah Sudwerts" <massu...@yahoo.com> wrote in message
news:41ab6fa0$0$3075$9a6e...@unlimited.newshosting.com...
Thank YOu Very Much,
Yoni
"Ken Slovak - [MVP - Outlook]" <kens...@mvps.org> wrote in message
news:uFTeHmu1...@TK2MSFTNGP15.phx.gbl...
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
ShellExecute(0&, "print", strPath, 0&, 0&, 0&)
Where strPath is the path to the file you want to print.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Yonah Sudwerts" <massu...@yahoo.com> wrote in message
news:41acd17c$0$27439$9a6e...@unlimited.newshosting.com...
(For that matter, How can I get this entire thing to run automatically on
new email, or so I have to use it manually through the Macro Menu)
It turns out I am a bit of a n00b, I do unserstand the script when looking
at it, but I don't get how to make it run.
Thanks for your help,
Yoni
"Ken Slovak - [MVP - Outlook]" <kens...@mvps.org> wrote in message
news:Oz$aKO71E...@TK2MSFTNGP10.phx.gbl...
Sub SaveAttachment()
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
'Set destination folder
myOrt = "C:\"
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
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
I understand most of what is going on. Problem 1 is that it only seems to
work on a selected email, not on an entire Folder.
Second problem is how would I implement the Entire Second stage, I am a bit
off on that part. Sorry.
(Last but not last, How would I automate it to run when new email comes in)
I would also add in to the end to send all processed (that fit the
description) emails to another folder.
Am I asking too much?
Thanks,
Yoni
I will copy what I have so far:
>>>Sub Save_Attachments_TESTER_Folder()
Dim objMsg As Object
Dim objAttachments As Outlook.Attachments
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolder As String
Dim MyFolder
On Error Resume Next
'Set myOlExp = Application.ActiveExplorer.CurrentFolder
'Set objSelection = Application.ActiveExplorer.Selection
Set MyFolder =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("TESTER")
strFolder = "c:\"
For Each objMsg In MyFolder.Items
'For Each objMsg In objSelection
Set objAttachments = objMsg.Attachments
lngCount = objAttachments.Count
If lngCount > 0 Then
For i = lngCount To 1 Step -1
strFile = strFolder & objAttachments.Item(i).FileName
objAttachments.Item(i).SaveAsFile strFile
Next i
End If
objMsg.Save
Next
ExitSub:
Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub>>>>>
I used a few different sources to help me get to this.
I have a few other, Outlook specific Questions, which I will put in a new
Post, since others mioght be able to help me as well.
Thanks,
Yoni
"Ken Slovak - [MVP - Outlook]" <kens...@mvps.org> wrote in message
news:Oz$aKO71E...@TK2MSFTNGP10.phx.gbl...
"Yonah Sudwerts" <massu...@yahoo.com> wrote in message
news:41aeff93$0$15785$9a6e...@unlimited.newshosting.com...
The declaration for the ShellExecute function should be at module level,
before any Subs or Functions are declared. In the ItemAdd handler put the
code to save the attachments. Use Application instead of declaring an
Outlook.Application object.
ItemAdd passes you an Item argument, check for Item.Class = olMail to make
sure it's an email. Then check for Item.Attachments.Count > 0. Then run the
attachment stripping code if True in a loop to get each attachment. After
saving each attachment you can check to see if it has a .TIFF extension. If
so then use the file path to call ShellExecute.
The other code you cited looks at Explorer.Selection, so of course it would
handle selected items in the current Explorer (folder view).
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Yonah Sudwerts" <massu...@yahoo.com> wrote in message
news:41ae29ea$0$11989$9a6e...@unlimited.newshosting.com...
For i = lngCount To 1 Step -1
strFile = strFolder & objAttachments.Item(i).FileName
objAttachments.Item(i).SaveAsFile strFile
ShellExecute 0&, "print", strFile, 0&, 0&, 0&
Next i
The declaration for ShellExecute should be at the module level, above and
subs or functions in that code or class module as follows:
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
'Then this:
Sub Save_Attachments_TESTER_Folder()
'and so on
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"saul kaye" <pha...@netvision.net.il> wrote in message
news:41af3931$0$15741$9a6e...@unlimited.newshosting.com...