save attachment using outlook 2007

Status
Not open for further replies.
S

Smlt

I have written a code to save and rename an attachment after an outlook rule

sorts the email into a folder. My issue is that I wrote it for outlook 2003

and we are currently being upgraded to outlook 2007. I have not programmed in

2007 (I am new to programming) and I am hoping someone can shed some light on

what changes I need to make so that it runs. Here is what I have:

Sub CAMPMM2(Item As Outlook.MailItem)

Set FSOC = CreateObject("scripting.filesystemobject")

filecountC = FSOC.GetFolder("M:\CAMPMM\").Files.Count

If filecontC > 0 Then

FSOC.deletefile "M:\CAMPMM\CAMPMM.zip"

End If

For Each Atmt In Item.Attachments

' This filename path must exist! Change folder name as

necessary.

ext = Atmt.FileName

ext = Right(ext, Len(ext) - InStrRev(ext, ".") + 1)

FileName = "M:\CAMPMM\CAMPMM" & ext

'Atmt.SaveAsFile FileName

Atmt.SaveAsFile FileName

i = i + 1

'Set Item = Item.FindNext

Next Atmt

End Sub

Thanks - Jim
 
K

Ken Slovak - [MVP - Outlook]

Virtually all Outlook macro code from versions prior to Outlook 2007 will

run unchanged in Outlook 2007. Your code is no exception.

"Jim" <Jim> wrote in message

news:F922D971-4F7B-4CE1-B808-B9733A70B9E6@microsoft.com...
> I have written a code to save and rename an attachment after an outlook
> rule
> sorts the email into a folder. My issue is that I wrote it for outlook
> 2003
> and we are currently being upgraded to outlook 2007. I have not programmed
> in
> 2007 (I am new to programming) and I am hoping someone can shed some light
> on
> what changes I need to make so that it runs. Here is what I have:

> Sub CAMPMM2(Item As Outlook.MailItem)

> Set FSOC = CreateObject("scripting.filesystemobject")
> filecountC = FSOC.GetFolder("M:\CAMPMM\").Files.Count

> If filecontC > 0 Then
> FSOC.deletefile "M:\CAMPMM\CAMPMM.zip"

> End If

> For Each Atmt In Item.Attachments
> ' This filename path must exist! Change folder name as
> necessary.

> ext = Atmt.FileName
> ext = Right(ext, Len(ext) - InStrRev(ext, ".") + 1)
> FileName = "M:\CAMPMM\CAMPMM" & ext
> 'Atmt.SaveAsFile FileName

> Atmt.SaveAsFile FileName
> i = i + 1
> 'Set Item = Item.FindNext

> Next Atmt
> End Sub

> Thanks - Jim
>
 
Status
Not open for further replies.
Top