procedure TFormMain.SendPic(Stream: TStream; FileName: string; PeerId: Integer; ReplyTo: Integer);
var
Url: string;
Response: TVkPhotoUploadResponse;
Photos: TVkPhotos;
begin
if VK.Photos.GetMessagesUploadServer(Url, PeerId) then
begin
if VK.Photos.Upload(Response, Url, Stream, FileName) then
try
if VK.Photos.SaveMessagesPhoto(Photos, Response) then
try
if ReplyTo <> 0 then
VK.Messages.New.PeerId(PeerId).ReplyTo(ReplyTo).Attachment(Photos.ToAttachments).Send.Free
else
VK.Messages.New.PeerId(PeerId).Attachment([FileName]).Send.Free;
finally
Photos.Free;
end;
finally
Response.Free;
end;
end;
end;