PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Re: Scriptproblem for the OL Rule Wizard

Reply

Re: Scriptproblem for the OL Rule Wizard

 
Thread Tools Rate Thread
Old 30-06-2003, 04:11 PM   #1
Ralf Meuser
Guest
 
Posts: n/a
Default Re: Scriptproblem for the OL Rule Wizard


It looks to me that the script isn't running since there is no MessageBox.
When I'm in Outlook XP I'll push Alt F11. In Modules I have Module1 where I
added the script.
After this I saved it. I hope this is alright, or have I to do something
else to valid the script.
In the Rule Wizard I started a blanc rules for incomming mail testing the
object for 'Test' and excute the script 'Project1.StripAttachments

Thanks again
Best regards

Ralf


"Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> a écrit dans le message
de news: ukCtRRLPDHA.2244@TK2MSFTNGP11.phx.gbl...
> I'm not sure what the problem is. I tested your code here and it
> worked when I ran the rule I made on existing items in an Inbox. There
> were 5 items with attachments in that Inbox and all of them were saved
> to the file system.
>
> I'd suggest a couple of things to try to troubleshoot the problem. Try
> adding 2 MessageBox function calls to see how the script is doing in
> the processing:
>
> Set objAttachments = Item.Attachments
> lngCount = objAttachments.Count
> MsgBox "Attachments count = " & lngCount '****NEW
> If lngCount > 0 Then
>
> ' code here
>
> strFile = strFolder & strFile
> ' Save the attachment as a file.
> MsgBox "Saving " & strFile '****NEW
> objAttachments.Item(i).SaveAsFile strFile
>
> The other thing is you have error handling commented out. Are you
> getting any errors in your code?
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm
>
> "Ralf Meuser" <rmeuser@tk-transports.fr> wrote in message
> news:3efc1270$0$12419$626a54ce@news.free.fr...
> > Thanks Ken, but it still doesn't work and I can't tell why not.
> > Please be so kind help me again.
> > Here is my script. I know that the rule is activate since it changes

> the
> > priorite as it was asked to do so in the same rules, but no

> attachement is
> > store in c:\uti\ol.
> >
> > Best regards
> >
> > Ralf
> >
> > --------------------------
> > Sub StripAttachments(Item As Outlook.MailItem)
> > Dim objAttachments As Outlook.Attachments
> > Dim i As Long
> > Dim lngCount As Long
> > Dim strFile As String
> > Dim strFolder As String
> >
> > 'On Error Resume Next
> >
> > ' Get the Temp folder.
> > strFolder = "c:\Uti\OL\"
> >
> > ' If attachments exist, save them to the Temp
> > ' folder and strip them from the item.
> > ' This code only strips attachments from mail items.
> > ' Get the Attachments collection of the item.
> > Set objAttachments = Item.Attachments
> > lngCount = objAttachments.Count
> > If lngCount > 0 Then
> > ' We need to use a count down loop for
> > ' removing items from a collection. Otherwise,
> > ' the loop counter gets confused and only every
> > ' other item is removed.
> > For i = lngCount To 1 Step -1
> > ' Save attachment before deleting from item.
> > ' Get the file name.
> > strFile = objAttachments.Item(i).FileName
> > ' Combine with the path to the Temp folder.
> > strFile = strFolder & strFile
> > ' Save the attachment as a file.
> > objAttachments.Item(i).SaveAsFile strFile
> > ' Delete the attachment
> > ' objAttachments.Item(i).Delete
> > Next i
> > End If
> >
> > Item.Save
> >
> > Set objAttachments = Nothing
> > End Sub

>
>




  Reply With Quote
Old 01-07-2003, 02:17 PM   #2
Ken Slovak - [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: Scriptproblem for the OL Rule Wizard

Saving it in Module1 is OK. I'd first try setting up a dummy calling
Sub that gets a mail item and then calls your script code, passing in
the Item argument. See if that code works. If it does with no problems
then I'm at a loss to explain why the script isn't running within the
rule.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm

"Ralf Meuser" <rmeuser@tk-transports.fr> wrote in message
news:3f006144$0$5406$626a54ce@news.free.fr...
> It looks to me that the script isn't running since there is no

MessageBox.
> When I'm in Outlook XP I'll push Alt F11. In Modules I have Module1

where I
> added the script.
> After this I saved it. I hope this is alright, or have I to do

something
> else to valid the script.
> In the Rule Wizard I started a blanc rules for incomming mail

testing the
> object for 'Test' and excute the script 'Project1.StripAttachments
>
> Thanks again
> Best regards
>
> Ralf



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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