-
Problem with reading mail attachment
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 'mapi1'
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 = 'false'
,@suppress_attach = 'true'
,@attachments = @attachments output
,@subject = @subject output
,@message = @message output
print @subject
print @message
print @attachments
if @status <> 0
begin
select @mapifailure=1
print 'mapi2'
print @status
end
set @attachments = 'copy /Y ' + @attachments + ' C: est.txt'
print @attachments
exec master..xp_cmdshell @attachments
end
-- END SQL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|