delphi - Not getting correct return value from Outlook -


i use following code send emails using outlook 2010 line

result := mailitem.sent; 

returns error

the item has been moved or deleted

how can fix function gives me useable return value?

function olsendmail(afrom, asubject, abody, ato, acc, abcc: string; amailfiles: tstringlist; areceipt: boolean = false; apreview: boolean = true): boolean; var   outlook: olevariant;   mailitem: olevariant;   i: integer;   mailinspector: variant; const   olmailitem = $00000000; begin   try     try       outlook := getactiveoleobject('outlook.application');     except       outlook := createoleobject('outlook.application');     end;     mailitem := outlook.createitem(olmailitem);     if olaccountvalid(afrom)       mailitem.sendusingaccount := outlook.session.accounts.item(afrom);     mailitem.to := ato;     mailitem.cc := acc;     mailitem.bcc := abcc;     mailitem.subject := asubject;     mailitem.body := abody;     := 0 amailfiles.count - 1       mailitem.attachments.add(amailfiles.strings[i]);     mailitem.readreceiptrequested := areceipt;     mailitem.originatordeliveryreportrequested := areceipt;      if apreview = true       begin         mailinspector := mailitem.getinspector;         mailinspector.display(true);       end     else       mailitem.send;     result := mailitem.sent;   except     on e:exception       begin         logfile.error('u_mailing.outlook.sendmailoutlook: ' + e.message);         result := false;       end;   end; end; 

after call sent, allowed operation release reference mailitem object - belongs spooler , asynchronously sent , moved sent items folder. @ moment (it different message now) sent property true , sender related properties populated.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -