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

Notification

Icon
Error

Options
Go to last post Go to first unread
nightfreak  
#1 Posted : Wednesday, February 15, 2017 4:13:06 AM(UTC)
nightfreak

Rank: Newbie

Groups: Registered
Joined: 2/15/2017(UTC)
Posts: 2
Austria

Hello,
in Delphi, I want to send a file as attachment which is stored in a TFileStream.
Does anyone know how to do this and could post the code for it?
I could only find examples for sending a file which is on my harddisk or a http source.

Thanks,
​​​​​​​Chris

ivan  
#2 Posted : Wednesday, February 15, 2017 5:03:26 PM(UTC)
ivan

Rank: Administration

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

Thanks: 9 times
Was thanked: 37 time(s) in 37 post(s)
Hi, you can use AddAttachment1 method:
https://www.emailarchite...l/sdk/?ct=addattachment1


Here is the example codes to convert MemoryStream to VARIANT, you need to read file to memory stream, then use AddAttachment1
Code:
function MemoryStreamToOleVariant(Strm: TMemoryStream): OleVariant;
var
  Data: PByteArray;
begin
 Result := VarArrayCreate([0, Strm.Size - 1], varByte);
 Data := VarArrayLock(Result);
 
 try

   Strm.Position := 0;
   Strm.ReadBuffer(Data^, Strm.Size);

 finally

   VarArrayUnlock(Result);

 end;
end;

Edited by user Monday, March 20, 2017 3:18:06 PM(UTC)  | Reason: Not specified

nightfreak  
#3 Posted : Thursday, February 16, 2017 9:50:06 AM(UTC)
nightfreak

Rank: Newbie

Groups: Registered
Joined: 2/15/2017(UTC)
Posts: 2
Austria

Thank you very much!!
This works for me :-)

Users browsing this topic
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-2019, Yet Another Forum.NET
This page was generated in 0.051 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AdminSystem Software Limited.