Trying to create a script that loops through all the emails in the inbox (and then I am supposed to perform certain operations, if certain data is found in the message).However I can't get it to work. I found several sample codes to loop through the email but nothnig seems to work. If I just write "exec xp_readmail" all emails are listed but when I try for instance the following code:DECLARE @status intDECLARE @hMessage varchar(255)DECLARE @MessageText varchar(8000)EXEC @status = xp_findnextmsg @unread_only='false',@msg_id=@hMessage OUTWHILE @status = 0BEGINexec xp_readmail @msg_id=@hMessage, @message=@MessageText OUTSELECT 'Message: ' + @MessageText SET @hMessage = NULLEXEC @status = xp_findnextmsg @unread_only='false',@msg_id=@hMessage OUTEND
which seems to have worked for others, I just get a loop showing the first message over and over again. It seems like a few others have had the same problem but I haven't found a solution.Or do I have to delete every email, after having read it.....?