PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Saving Attachments - Redemption
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Saving Attachments - Redemption
![]() |
Saving Attachments - Redemption |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I'm sandboxing with Redemption to see if it will do my task. So far I can send emails with attachments, no problem - Outlook 2K. The code below is retrieving replies, saving the Attachments to strPath and deleting the message - except the saveasfile fails. I also tried SafeItem.Attachments.Save, same error 438 property not supported. Read a lot of the Google threads but don't see alternative to Save or SaveAsFile. Can someone point me in the right direction? Code: Dim SafeItem As Object Dim objOutlook As Object Dim oNamespace As Object Dim Utils As Redemption.MAPIUtils Dim oOutlookItems As Object Dim oOutlookItem As Object Dim arrSubject As Variant Dim strUserFilename As String Dim strPath As String ' ' SET UP OUTLOOK Set objOutlook = CreateObject("Outlook.Application") Set oNamespace = objOutlook.GetNamespace("MAPI") oNamespace.Logon ' SET UP REDEMPTION Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of RedemptionSafeMailItem Set Utils = CreateObject("Redemption.MAPIUtils") 'Create an instance of Redemption.MAPIUtils ' GET INBOX CONTENTS Set oOutlookItems = objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items ' LOOK AT EACH ITEM IN THE INBOX For Each oOutlookItem In oOutlookItems 'test for items in the subject line (PWAttach & ProjID), then assign the item to SafeItem If InStr(1, oOutlookItem.Subject, "PWAttach", vbTextCompare) <> 0 Then 'test for ProjID arrSubject = Split(oOutlookItem.Subject, ",") For i = 0 To UBound(arrSubject) If arrSubject(i) = "PWAttach" Then If arrSubject(i + 1) = gOptions.ActiveProjectID Then 'this is one of our replies strUserFilename = arrSubject(i + 2) SafeItem.Item = oOutlookItem 'get the UF path strPath = GetUFPath(strUserFilename) 'overwrite the file SafeItem.Attachments.SaveAsFile strPath 'delete the message SafeItem.Item.Delete End If End If Next End If Next 'clean up happens later... Thanks for any help, Jim Spicer |
|
|
|
#2 |
|
Guest
Posts: n/a
|
SafeItem.Attachments.SaveAsFile strPath
There is no SaveAsFile method for the Attachments collection. That method must be called on an individual Attachment in that collection. Does this work? SafeItem.Attachments.Item(1).SaveAsFile strPath -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginners Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "news.microsoft.com" <jim@spicer-baer.com> wrote in message news:edgswXZ9DHA.2608@TK2MSFTNGP10.phx.gbl... > Hi, > I'm sandboxing with Redemption to see if it will do my task. So far I can > send emails with attachments, no problem - Outlook 2K. > > The code below is retrieving replies, saving the Attachments to strPath and > deleting the message - except the saveasfile fails. I also tried > SafeItem.Attachments.Save, same error 438 property not supported. > > Read a lot of the Google threads but don't see alternative to Save or > SaveAsFile. Can someone point me in the right direction? > > Code: > Dim SafeItem As Object > Dim objOutlook As Object > Dim oNamespace As Object > Dim Utils As Redemption.MAPIUtils > Dim oOutlookItems As Object > Dim oOutlookItem As Object > Dim arrSubject As Variant > Dim strUserFilename As String > Dim strPath As String > ' > ' SET UP OUTLOOK > Set objOutlook = CreateObject("Outlook.Application") > Set oNamespace = objOutlook.GetNamespace("MAPI") > oNamespace.Logon > ' SET UP REDEMPTION > Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an > instance of RedemptionSafeMailItem > Set Utils = CreateObject("Redemption.MAPIUtils") 'Create an > instance of Redemption.MAPIUtils > ' GET INBOX CONTENTS > Set oOutlookItems = > objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items > ' LOOK AT EACH ITEM IN THE INBOX > For Each oOutlookItem In oOutlookItems > 'test for items in the subject line (PWAttach & ProjID), then assign > the item to SafeItem > If InStr(1, oOutlookItem.Subject, "PWAttach", vbTextCompare) <> 0 > Then > 'test for ProjID > arrSubject = Split(oOutlookItem.Subject, ",") > For i = 0 To UBound(arrSubject) > If arrSubject(i) = "PWAttach" Then > If arrSubject(i + 1) = gOptions.ActiveProjectID Then > 'this is one of our replies > strUserFilename = arrSubject(i + 2) > SafeItem.Item = oOutlookItem > 'get the UF path > strPath = GetUFPath(strUserFilename) > 'overwrite the file > SafeItem.Attachments.SaveAsFile strPath > 'delete the message > SafeItem.Item.Delete > End If > End If > Next > End If > Next > 'clean up happens later... > > Thanks for any help, > Jim Spicer > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Yes, Ken Thank you. Another set of experienced eyes is invaluable.
Now I guess I'll try to do something besides plow through the entire Inbox. thanks again, Jim "Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message news:OBUE8tZ9DHA.2432@TK2MSFTNGP10.phx.gbl... > SafeItem.Attachments.SaveAsFile strPath > > There is no SaveAsFile method for the Attachments collection. That > method must be called on an individual Attachment in that collection. > Does this work? > > SafeItem.Attachments.Item(1).SaveAsFile strPath > > > -- > Ken Slovak > [MVP - Outlook] > http://www.slovaktech.com > Author: Absolute Beginners Guide to Microsoft Office Outlook 2003 > Reminder Manager, Extended Reminders, Attachment Options > http://www.slovaktech.com/products.htm > > > "news.microsoft.com" <jim@spicer-baer.com> wrote in message > news:edgswXZ9DHA.2608@TK2MSFTNGP10.phx.gbl... > > Hi, > > I'm sandboxing with Redemption to see if it will do my task. So far > I can > > send emails with attachments, no problem - Outlook 2K. > > > > The code below is retrieving replies, saving the Attachments to > strPath and > > deleting the message - except the saveasfile fails. I also tried > > SafeItem.Attachments.Save, same error 438 property not supported. > > > > Read a lot of the Google threads but don't see alternative to Save > or > > SaveAsFile. Can someone point me in the right direction? > > > > Code: > > Dim SafeItem As Object > > Dim objOutlook As Object > > Dim oNamespace As Object > > Dim Utils As Redemption.MAPIUtils > > Dim oOutlookItems As Object > > Dim oOutlookItem As Object > > Dim arrSubject As Variant > > Dim strUserFilename As String > > Dim strPath As String > > ' > > ' SET UP OUTLOOK > > Set objOutlook = CreateObject("Outlook.Application") > > Set oNamespace = objOutlook.GetNamespace("MAPI") > > oNamespace.Logon > > ' SET UP REDEMPTION > > Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create > an > > instance of RedemptionSafeMailItem > > Set Utils = CreateObject("Redemption.MAPIUtils") 'Create > an > > instance of Redemption.MAPIUtils > > ' GET INBOX CONTENTS > > Set oOutlookItems = > > > objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items > > ' LOOK AT EACH ITEM IN THE INBOX > > For Each oOutlookItem In oOutlookItems > > 'test for items in the subject line (PWAttach & ProjID), > then assign > > the item to SafeItem > > If InStr(1, oOutlookItem.Subject, "PWAttach", vbTextCompare) > <> 0 > > Then > > 'test for ProjID > > arrSubject = Split(oOutlookItem.Subject, ",") > > For i = 0 To UBound(arrSubject) > > If arrSubject(i) = "PWAttach" Then > > If arrSubject(i + 1) = gOptions.ActiveProjectID > Then > > 'this is one of our replies > > strUserFilename = arrSubject(i + 2) > > SafeItem.Item = oOutlookItem > > 'get the UF path > > strPath = GetUFPath(strUserFilename) > > 'overwrite the file > > SafeItem.Attachments.SaveAsFile strPath > > 'delete the message > > SafeItem.Item.Delete > > End If > > End If > > Next > > End If > > Next > > 'clean up happens later... > > > > Thanks for any help, > > Jim Spicer > > > > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

