[mso] Re: Rules don't rule

  • From: "Greg Chapman" <greg@xxxxxxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Tue, 7 Oct 2003 10:47:53 -0500

Whatcha tryin' to do, exactly?

There were several complaints that outlook made to me while running this
and it seemed to indicate that you are building some sort of Class (all
those WithEvents indicated that you needed to create event handlers on the
fly for some of your controls. Once I cleared through that,I saw the
behavior you saw and simplified the problem as below:
Option Explicit

Private Sub Application_NewMail()
' New Mail
Dim oFolder As Object
Dim oNewItem As MailItem

    On Error Resume Next
    Set oFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    'Stop
    MsgBox oFolder.Items.Count
    For Each oNewItem In oFolder.Items.Restrict("[Unread] = 0")
        If oNewItem.BodyFormat = olFormatHTML Then
            oNewItem.Display
            oNewItem.BodyFormat = olFormatPlain
            oNewItem.Display
        End If
    Next                  ' Line D
End Sub

What confused me is that it appears you're trying to create new mail and
make sure its format is not HTML. But, the routine you had actually cycles
through unread messages and converts them from HTML to plain text. So,
like, what's up?<g>

Greg Chapman
http://www.mousetrax.com
"Counting in binary is as easy as 01, 10, 11!
With thinking this clear, is coding really a good idea?"


> -----Original Message-----
> From: mso-bounce@xxxxxxxxxxxxx
> [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of Green
> Sent: Tuesday, October 07, 2003 10:41 AM
> To: mso@xxxxxxxxxxxxx
> Subject: [mso] Re: Rules don't rule
>
>
> Hello all,
>
> I'm affraid I might be hitting my head against a brick wall
> with trying to
> conquer Outlook rules but I'm rather stubborn so if this is
> getting boring
> please don't shout at me too loudly.
>
> Can anyone tell me why this doesn't work
> Line A gets run then Line B and then Line D!! Line C doesn't
> get run at all!
>
> Option Explicit
>
> Public WithEvents oItem As MailItem
> Public WithEvents oInspector As Inspector
> Public WithEvents oInspectors As Inspectors
> Public WithEvents oControl As CommandBarButton
>
> Private Sub Application_NewMail()
> ' New Mail
> Dim oFolder As Object
> Dim oNewItem As MailItem
>
>     On Error Resume Next
>     Set oFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
>     Stop
>     'Exit Sub
>     MsgBox oFolder.Items.Count
>     For Each oNewItem In oFolder.Items.Restrict("[Unread] = 0")
>         oItem = oNewItem
>         StripHTMLBody     ' Line A
> '        oItem.Save
>     Next                  ' Line D
> End Sub
>

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: