Hi,
I want to save attachment from email. Problem is that I got empty file,
because xp_readmail puts empty temp file for attachment in Temp folder. Why?
If I change parameter @suppress_attach to false, I'm getting error
"xp_readmail: failed with mail error 0x80004005". I still can get mail
subject and body, but no attachment. Maybe I have problem with permissions?
I am using Enterprise SQL 2000 and Outlook 2000 SP1, on Windows 2000
Advanced Server.
Thanks in advance
Nikola Milic

-- BEGIN SQL
-- To run this script you must have one UNREADED mail with attachment in
mail box

declare @status int
declare @msg_id varchar(64)
declare @current_msg varchar(64)
declare @subject varchar(255)
declare @message varchar(255)
declare @attachments varchar(255)
declare @mapifailure int
set @mapifailure = 0


exec @status = master..xp_findnextmsg
@msg_id=@msg_id output
, @unread_only='true'


if @status <> 0
begin
select @mapifailure=1
print &#39;mapi1&#39;
print @msg_id
print @status
end

declare @counter int
set @counter = 0
while (@mapifailure=0) and @counter < 1
begin
print @counter
select @counter = @counter + 1

exec @status = master..xp_readmail @msg_id = @msg_id
,@peek = &#39;false&#39;
,@suppress_attach = &#39;true&#39;
,@attachments = @attachments output
,@subject = @subject output
,@message = @message output

print @subject
print @message
print @attachments

if @status <> 0
begin
select @mapifailure=1
print &#39;mapi2&#39;
print @status
end


set @attachments = &#39;copy /Y &#39; + @attachments + &#39; C: est.txt&#39;
print @attachments
exec master..xp_cmdshell @attachments

end

-- END SQL