New Blog Post: PDF/A and Metadata

Multiple Attachments

edited February 2010 in General
Delphi 2009, RB Standard 11.07 Build 2

The following code will sometimes result in multiple email attachments of
the PDF file:

TppSMTPPlugIn.RegisterClass(TppSMTPIndy);

TppEmail(ppAcknowledge.Email).SMTP.OnEmailError := EmailErrorEvent;

ppAcknowledge.EMailSettings.Clear;

ppAcknowledge.EmailSettings.Subject := 'Order Acknowledgement for: ' +
tblOrderHeaderCustQuoteReference.AsString;

ppAcknowledge.EmailSettings.Body.Add('Your order acknowledgement is
Attached.' + #13#10 + 'Thank you for your order.');
ppAcknowledge.EmailSettings.Body.Add('');
ppAcknowledge.EmailSettings.Body.Add('');
ppAcknowledge.EmailSettings.Body.Add('Regards,');
ppAcknowledge.EmailSettings.Body.Add(OPUserFullName);
ppAcknowledge.EmailSettings.Body.Add(CompName);
ppAcknowledge.EmailSettings.Body.Add('');
ppAcknowledge.EmailSettings.Body.Add(EMailDisclaimer);
//ppAcknowledge.EmailSettings.Body.Add('Sales Team');
ppAcknowledge.EMailSettings.Recipients.Clear;
ppAcknowledge.EmailSettings.Recipients.Add(tblContactLookupEMail1.asString);
ppAcknowledge.EmailSettings.BlindCarbonCopy.Clear;
ppAcknowledge.EmailSettings.BlindCarbonCopy.Add(OPUserEMail);
ppAcknowledge.EmailSettings.ReportFormat := 'PDF';
ppAcknowledge.EmailSettings.FileName :=
ReturnStrThatIsFileValid(tblOrderHeaderCustQuoteReference.asString,'NOQUOTEREF')
+ '.PDF';

NOTE: ReturnStrThatIsFileValid function simply strips all
characters but alphanumeric.

ppAcknowledge.EmailSettings.FromAddress := OPUserEMail;
ppAcknowledge.EmailSettings.FromName := OPUserFullName;

ppAcknowledge.EMailSettings.Attachments.Clear;

ppAcknowledge.EmailSettings.ReplyTo := OPUserEmail;
ppAcknowledge.EmailSettings.HostAddress := DefHostAddress;
ppAcknowledge.EmailSettings.ShowEmailDialog := True;
ppAcknowledge.EmailSettings.PreviewInEmailClient := False;


ppAcknowledge.SendMail;

The only other note that I think may be relevant is that I updated the indy
10 in Delphi from V10.2.5 to V10.5.5. It is so far only occuring in the
live implementation not in my development environment.

Any thoughts would be appreciated,
Peter.

Comments

  • edited February 2010
    Hi Peter,

    This is not a known issue however I do know that Indy 10 has had issues with
    attachments in recent versions. You can trace through the
    TppEmail.ProcessAndSend code and the TppSMTPIndy code to see if more than
    one attachments is being added before Indy takes over. You might also try
    either moving back to the previous version of Indy that you were using or
    perhaps moving to a different email library such as Synapse.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.