koden Posted July 28, 2006 Report Share Posted July 28, 2006 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 Quote Link to comment Share on other sites More sharing options...
jason Posted July 28, 2006 Report Share Posted July 28, 2006 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. Quote Link to comment Share on other sites More sharing options...
koden Posted July 28, 2006 Author Report Share Posted July 28, 2006 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?????????????? Quote Link to comment Share on other sites More sharing options...
joe Posted July 29, 2006 Report Share Posted July 29, 2006 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> Quote Link to comment Share on other sites More sharing options...
koden Posted July 31, 2006 Author Report Share Posted July 31, 2006 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> Quote Link to comment Share on other sites More sharing options...
joe Posted July 31, 2006 Report Share Posted July 31, 2006 Your additional code seems correct. The gobblygook at the bottom of the Code section is the actual code of example above it. You can cut-and-paste it to you macro. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.