Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ivan  
#1 Posted : Monday, October 28, 2013 6:57:35 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,148

Thanks: 9 times
Was thanked: 54 time(s) in 54 post(s)
in EAGetMail Attachment object,
Attachment.Content property returns binary data with SafeArray Type.

Many Delphi users asked me how to convert the SafeArray to Stream in delphi,
Here is the example code:



procedure TForm1.LoadAttToStream( att: IAttachment );
var
i: integer;
lbound: integer;
ubound: Integer;
len: integer;
buffer: array of byte;
myarray: OleVariant;
stream: TMemoryStream;
begin

myarray := att.Content;
lbound := VarArrayLowBound(myarray, 1 );
ubound := VarArrayHighBound(myarray, 1 );
len := ubound - lbound + 1;
if len = 0 then
exit;

SetLength( buffer, len );
for i := VarArrayLowBound(myarray, 1 ) to ubound do
begin
buffer[i] := VarArrayGet( myarray, i );
end;

stream := TMemoryStream.Create();

stream.WriteBuffer( buffer[0], len );
stream.SaveToFile( 'c:\my folder\' + att.Name ); //save stream to file.
stream.Free();
end;

Edited by user Friday, November 8, 2013 6:58:15 PM(UTC)  | Reason: Not specified

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.046 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.