Delphi XE8 ile IOS ve Android için Foto Çek Gönder

Tuncay ÖZER Tuncay ÖZER


Şubat 2019 Delphi (2) 0


Delphi XE8 ile IOS ve Android için Foto Çek Gönder

Merhaba geçmişte bir forumda yazmış olduğum (2014 yılı) Embarcadero Delphi XE8 kullanarak Cross Platform (Windows, IOS, Android) da kullanmak üzere cihazlardan çek gönder uygulaması örneği paylaşmıştım. Umarım işinizi görür.

function Tcekgonder.SendEmail(sendTo: string;
subject: string;
body: string;
attachFiles: TStringList;
smtpHost: string;
smtpPort: Integer;
smtpUser: string;
smtpPass: string;
tls: TIdUseTLS): boolean;
var
smtp: TIdSmtp;
ssl: TIdSSLIOHandlerSocketOpenSSL;
msg: TIdMessage;
i: Integer;
begin
smtp:=TIdSmtp.Create(nil);
ssl:=TIdSSLIOHandlerSocketOpenSSL.Create(nil);
msg:=TIdMessage.Create(nil);

msg.ContentType:= 'text/html; charset=UTF-8';
try

try
smtp.Host:=smtpHost;
smtp.Port:=smtpPort;
smtp.Username:=smtpUser;
smtp.Password:=smtpPass;

//smtp.OnConnected :=IdSMTP1Connected;
//smtp.OnDisconnected :=IdSMTP1Disconnected;
//smtp.OnFailedRecipient :=IdSMTP1FailedRecipient;
//smtp.OnStatus :=IdSMTP1Status;
//smtp.OnTLSNotAvailable :=IdSMTP1TLSNotAvailable;
//smtp.OnWork :=IdSMTP1Work;

if not (tls=utNoTLSSupport) then begin
ssl.Destination:=smtpHost + ':' + IntToStr(smtpPort);
ssl.Host:=smtpHost;
ssl.Port:=smtpPort;
ssl.SSLOptions.Method:=sslvTLSv1;

//ssl.OnStatusInfo:=IdSSLIOHandlerSocketOpenSSL1StatusInfo;
//ssl.OnGetPassword:=IdSSLIOHandlerSocketOpenSSL1GetPassword;
//ssl.OnStatus:=IdSSLIOHandlerSocketOpenSSL1Status;

smtp.IOHandler:=ssl;
smtp.UseTLS:=tls;
end;

msg.Recipients.EMailAddresses := sendTo;
msg.Subject:=subject;
msg.Body.Text:=body;

if(Assigned(attachFiles)) then begin
for i := 0 to attachFiles.Count - 1 do begin
if FileExists(attachFiles) then
TIdAttachmentFile.Create(msg.MessageParts, attachFiles);
end;
end;

smtp.Connect;
smtp.Send(msg);
smtp.Disconnect;
showmessage('Mailiniz gönderilmiştir');
result:=true;
finally
msg.Free;
ssl.Free;
smtp.Free;
end;
except
result:=false;
end;

end;

--------------------------------------------------------------------------
procedure Tcekgonder.Button1Click(Sender: TObject);

var

attachmentFiles: TStringList;

begin


//KodDogrula (TCkimlik.Text);
attachmentFiles:=TStringList.Create;
try

attachmentFiles.Add(System.IOUtils.TPath.GetDocumentsPath+'/cekgonder.jpg');

try

SendEmail( 'tuncay.ozer@gmail.com.',
''+tckimlik.Text+' - Çek Gönder Istegi',
''+TCKimlik.Text+'</br>'+telefon.Text+'</br>'+ mesaj.text +'',
attachmentFiles,
'smtp.gmail.com',
587,
'istekyapanlar@gmail.com',
'*********şifre ********', utUseExplicitTLS);
except
on E : Exception do
begin
ShowMessage('EXCEPTION: message=' + E.Message);
end;
end;
finally
attachmentFiles.Free;
FileExists (System.IOUtils.TPath.GetDocumentsPath+'/cekgonder.jpg');
end;
end;

-------------------------------------------------------------------------------------------
procedure Tcekgonder.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
var
ScaleFactor: Single;
begin
if image.Width > 1024 then
begin
ScaleFactor := image.Width / 1024;
image.Resize(Round(Image.Width / ScaleFactor), Round(Image.Height / ScaleFactor));

end;

self.resim.Bitmap.Assign(Image);
self.resim.Bitmap.SaveToFile(System.IOUtils.TPath.GetDocumentsPath+'/cekgonder.jpg');

end;