+ Reply to Thread
Results 1 to 2 of 2

Thread: Outlook VB Code Help.

  1. #1
    focus is offline x10 Sophmore focus is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    112

    Outlook VB Code Help.

    Can someone please help me get the OR statement to work?


    When i have the code as below it works fine.

    Code:
    If currF.Name = "modifytest" Then
        If currF.Items.Count >= 1 Then
            For Each msg In currF.Items
                subjName = msg.subject
                If (InStr(1, subjName, "ACE-TOKENS") > 0 And InStr(1, subjName, "Modify") > 0 And InStr(1, subjName, "[") = 0 And InStr(1, subjName, "SUCCESS") = 0 And InStr(1, subjName, "FAIL") = 0 And InStr(1, subjName, "AUTO_CHECKED") = 0) Then
                If (InStr(1, findwhatever(msg.Body, "mytokennumber:"), "Empty") > 0) Then
                    'find user details
                    useId = useId & Trim(findwhatever(msg.Body, "Login Id:")) & Chr(10)
                    msg.subject = "(AUTO_CHECKED)" & msg.subject
                    msg.Save
                    
                    
                ElseIf (InStr(1, findwhatever(msg.Body, "mytokennumber:"), "Empty") = 0) Then
                    msg.subject = "(HAVE TOKEN)" + subjName
                    msg.UnRead = True
                    msg.Save
                    
    
                    
                End If
                End If
    However if i add an OR statement so i can also check if "mytokenaccessgroups:" is in the body it marks all the emails as (AUTO_CHECKED)...

    Code:
    If currF.Name = "modifytest" Then
        If currF.Items.Count >= 1 Then
            For Each msg In currF.Items
                subjName = msg.subject
                If (InStr(1, subjName, "ACE-TOKENS") > 0 And InStr(1, subjName, "Modify") > 0 And InStr(1, subjName, "[") = 0 And InStr(1, subjName, "SUCCESS") = 0 And InStr(1, subjName, "FAIL") = 0 And InStr(1, subjName, "AUTO_CHECKED") = 0) Then
                
                'added or statement
                If (InStr(1, findwhatever(msg.Body, "mytokennumber:"), "Empty") > 0) Or (InStr(1, findwhatever(msg.Body, "mytokenaccessgroups:"), "Empty") > 0) Then
                    'find user details
                    useId = useId & Trim(findwhatever(msg.Body, "Login Id:")) & Chr(10)
                    msg.subject = "(AUTO_CHECKED)" & msg.subject
                    msg.Save
                    
                    
                ElseIf (InStr(1, findwhatever(msg.Body, "mytokennumber:"), "Empty") = 0) Or (InStr(1, findwhatever(msg.Body, "mytokenaccessgroups:"), "Empty") = 0) Then
                    msg.subject = "(HAVE TOKEN)" + subjName
                    msg.UnRead = True
                    msg.Save
                    
    
                    
                End If
                End If

    Please note that if i use the first piece of code and change "mytokennumber:" to "mytokenaccessgroups:" it also works.

  2. #2
    vv.bbcc19's Avatar
    vv.bbcc19 is offline Community Advocate vv.bbcc19 is just really nice
    Join Date
    Jun 2010
    Location
    India
    Posts
    1,505

    Re: Outlook VB Code Help.

    I think you should check with or statement separately outside the if statements.
    Try once.
    BCV | Community Support Representative
    █ x10Hosting - Giving Away Hosting Since 2004
    Premium Hosting | VPS Services

+ Reply to Thread

Similar Threads

  1. Email Setup on outlook
    By grod77748 in forum Free Hosting
    Replies: 1
    Last Post: 08-12-2010, 12:07 AM
  2. Outlook
    By caribbeanit in forum Free Hosting
    Replies: 1
    Last Post: 01-03-2010, 05:08 AM
  3. [PHP and mySQL]Emails to outlook
    By galaxyAbstractor in forum Tutorials
    Replies: 0
    Last Post: 08-18-2008, 08:42 AM
  4. cant set up email for outlook
    By alisami83 in forum Free Hosting
    Replies: 1
    Last Post: 01-02-2008, 07:07 PM
  5. i need help for setting up MS Outlook 2007
    By stolenshots in forum Free Hosting
    Replies: 4
    Last Post: 10-05-2007, 08:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers