Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
spudhead
Starting Member
34 Posts |
Posted - 2002-10-24 : 10:16:18
|
| Hi,Apologies to all those who've read the post at http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=20975 - this is a bit of a cross-post. But not entirely :)I've got round the error message it was generating, but it's still ignoring this 'if' statement, and I've NO idea why. I've tried various checks, including:IF (@MessageSubject LIKE '%Undeliverable%')andIF (@Origin LIKE '%System%')(where @Origin is the sender of the email; 'System Administrator')It's just not deleting the email, and it SHOULD. Does anyone know why?IF (CHARINDEX('Undeliverable', @MessageSubject)>0) BEGIN exec master.dbo.xp_deletemail @msg_id=@hMessageEND |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-10-24 : 10:28:39
|
| Is there anything in the NT event log to suggest that the delete command is failing, or is it not even getting to that point?What happens if you replace the deletemail command with something else just to test the IF statement itself? |
 |
|
|
spudhead
Starting Member
34 Posts |
Posted - 2002-10-24 : 10:44:31
|
| Umm - how do I get to the NT event log again? (On Win2000) But yeah, I don't think it's even getting that far. If I replace the delete command with, say; PRINT 'Hello world', nothing gets printed. But I can open up (with Outlook) the mailbox that it's reading and clearly see a big stack of Undeliverable notification emails from 'System Administrator'. |
 |
|
|
srf
Starting Member
42 Posts |
Posted - 2002-10-24 : 12:55:54
|
| Start -> Run -> Eventvwr.Have you tried looking at the mail without Outlook, or looking at @MessageSubject itself?If I email a bad address on an Exchange server using Outlook Express, the message I get reads "Delivery Status Notification (Failure)" instead of "Undeliverable:" |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-10-25 : 03:23:54
|
| I agree in that case it looks as though your charindex search is looking for the wrong string in the title. To confirm I would have the SQL print out @messagesubject, I think. |
 |
|
|
|
|
|
|
|