xp_readmail: failed with operating system error 80

Recently I came across a question where the user was having issues with xp_readmail. This extended stored procedure was being used inside a stored procedure to process the e-mails using SQLMail. It was working fine and suddenly it stopped working with the below error message.

xp_readmail: failed with operating system error 80 [SQLSTATE 42000] (Error 18024)

Before digging deep into the error, a quick review of how SQLMail works. It makes use of an Extended MAPI profile of the SQL Server service account. This requires that the Service Account has a Mailbox configured and on the Server running SQL Server, outlook has to be configured for this account. For processing mails it will make use of the temp directory on the profile folder (C:\Documents and Settings\[ServiceAccount]\Local Settings\) for SQL Server service account.

Now coming back to the error message, operating system error 80 means The file exists. Since it is related to SQLMail, it is clear that the issue is not with SQL Server. While processing the mails, it is encountering file exists error on the operating system. This can happen if the folder on which the use profile folder (Documents and Settings) resides is running out of space. In this case it is C drive. Or if the files created on the temp directory did not get cleared up due to some reason and it is trying to create the same file again.

When I came across a similar issue on xp_sendmail, I cleared up the contents of C:\Documents and Settings\[ServiceAccount]\Local Settings\Temp folder and restarted SQLMail. This had fixed the issue. This time I got a “Thanks Pradeep, solved” reply, I assume that the user would have done the same workaround to fix this issue.

One thought on “xp_readmail: failed with operating system error 80

Comments are closed.