Jump to content
Macro Express Forums

Use Case,switch Or If?


koden
 Share

Recommended Posts

I copy the subject field from a lot of mails into T1

Then i test the content.

 

But what is best to use? case,switch or if....

 

If the word "Nordea" or "USD sag" or "slettet" appears in T1 the mail has to be deleted.

 

If the word "oprettet" appears in T1 the macro schould take action on the mail.

 

If the word "flyttet" appears in T1 the macro schould take action on the mail.

 

Sometimes "oprettet" and "nordea" appears in T1 together. If that, the mail has to be deleted.

 

 

------------------------------------------------------------

 

at the moment i use

If T1 contains

Nordea

OR

USD sag

OR

slettet

Then delete mail

end if

If T1 contains

Oprettet

and

nordea

Then delete mail

end if

If T1 contains

oprettet

then "do something with mail"

end if

 

 

But do I need this?:

 

If T1 contains

Oprettet

and

nordea

Then delete mail

end if

 

when I have had this in the start:

 

If T1 contains

Nordea

OR

USD sag

OR

slettet

Then delete mail

end if

Link to comment
Share on other sites

The macro should be looking for the text Nordea, USD sag and slettet. If if sees any one of those words, it should delete the email when using the OR statement.

 

If you use the AND statement, it will require all of the conditions to be true instead of just condition.

Link to comment
Share on other sites

Okay.. so this is okay:

 

If T1 contains

Nordea

OR

USD sag

OR

slettet

Then delete mail

end if

 

This will delete mails where one of the word appears.

 

But if none of the words appears and the word "oprettet" appears i T1

then it will go on to the next if statement:

 

If T1 contains

oprettet

then "do something with mail" (another macro).

end if

 

If none of the 4 words appears in T1 it will go on to the next if statement (if there is anyone) or it will stop??????????????

Link to comment
Share on other sites

The Switch / End Switch construct only works with exact matches. In other words, contains or does not contain is not possible. Therefore, you need to use the If / Else / End If construct for your testing. The following code should do the job:

If Variable %T1% contains "flyttet"
 // ...
 // Process mail
 // ...
Else
 If Variable %T1% contains "oprettet"
   AND
 If Variable %T1% does not contain "nordea"
   // ...
   // Process mail
   // ...
 Else
   // ...
   // Delete mail
   // ...
 End If
End If


<IFVAR2:1:01:7:Tflyttet><REM2:...><REM2:Process mail><REM2:...><ELSE><IFVAR2:1:01:7:Toprettet><AND><IFVAR2:1:01:8:Tnordea><REM2:...><REM2:Process mail><REM2:...><ELSE><REM2:...><REM2:Delete mail><REM2:...><ENDIF><ENDIF>

Link to comment
Share on other sites

Thanks for the code and explanation.

 

I have one more word EMAIL that has to be handelt.

 

flyttet, oprettet and email has to be handelt in 3 different ways, just for your inf.

 

 

is this the right way with an OR command:

 

If Variable %T1% contains "flyttet"

// ...

Process mail like process 1

OR

If Variable %T1% contains "email"

Process mail like process 2

// ...

Else

If Variable %T1% contains "oprettet"

AND

If Variable %T1% does not contain "nordea"

// ...

// Process mail

// ...

Else

// ...

// Delete mail

// ...

End If

End If

 

 

 

But what is this:

 

<IFVAR2:1:01:7:Tflyttet><REM2:...><REM2:Process mail><REM2:...><ELSE><IFVAR2:1:01:7:Toprettet><AND><IFVAR2:1:01:8:Tnordea><REM2:...><REM2:Process mail><REM2:...><ELSE><REM2:...><REM2:Delete mail><REM2:...><ENDIF><ENDIF>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...