Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Sending Email

edited April 2010 in General
I'm looking for a way to change the port number and the 'Use Authentication'
flag on outgoing email.

I'm using Report Builder Enterprise 11.08, Delphi 2010, and Windows 7.

Thanks for your time
Dusten
Frontline Software Technology, Inc.


Comments

  • edited April 2010
    Hi Dusten,

    Use the IndySMTP public property of the Indy plugins to gain access to the
    TIdSMTP object used. You can change the port used in code with something
    similar to the following.

    var
    lEmail: TppEmail;
    begin

    lEmail := TppEmail(Report.Email);
    TppSMTPIndy(lEmail.SMTP).IndySMTP.Port := ;


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2010
    Thanks for your time Nico,

    I'm still having troubles getting this feature to work. Even with the simple
    demo project from digital-metaphors. I'd love to get it working though,
    because we've had to go through a not-so-great component to do this job.
    Anyway, I've setup my own simple project based off the demo and just cannot
    get an email to go through. I'm using GMail as an email host. Here's the
    send code: (ppReport1.EmailSettings.Enabled is True)

    //Register Email Component
    TppSMTPPlugIn.RegisterClass(TppSMTPIndy);

    //Set email account defaults
    ppReport1.EmailSettings.HostAddress := 'smtp.gmail.com';
    ppReport1.EmailSettings.UserName := 'myaccount@gmail.com';
    ppReport1.EmailSettings.Password := 'mypassword';

    //set email to/from fields
    ppReport1.EmailSettings.Recipients.Add('delphi@gofrontline.com');
    ppReport1.EmailSettings.FromAddress := 'myaccount@gmail.com';
    ppReport1.EmailSettings.ReplyTo := 'myaccount@gmail.com';

    //set email subject/body
    ppReport1.EmailSettings.Subject := 'Test Email From Report Builder';
    ppReport1.EmailSettings.Body.Add('This is a test email from report
    builder.');

    //set advanced properties
    lEmail := TppEmail(ppReport1.Email);
    // TppSMTPIndy(lEmail.SMTP).IndySMTP.Port := 25;
    // TppSMTPIndy(lEmail.SMTP).IndySMTP.AuthType := satSASL;
    TppSMTPIndy(lEmail.SMTP).OnEmailError := EmailErrorEvent;

    //send report
    ppReport1.SendMail;

    As you can see I attached an EmailErrorEvent but nothing comes up and
    nothing comes through to the gofrontline account.

    Any ideas?

    Thanks again for your time
    Dusten Scheere
    Frontline Software Technology, Inc.
  • edited April 2010
    I'm not familiar e-mailing using these components, but I'm familiar with POP
    and SMTP settings for gmail.

    The SMTP server requires authentication, TLS and uses either port 465 or
    587. Make sure you're outoing mail settings are correct.

    A.J. van de Ven

  • edited April 2010
    Thanks for the information A.J

    Here's some updated code

    //set advanced properties
    lEmail := TppEmail(ppReport1.Email);
    TppSMTPIndy(lEmail.SMTP).IndySMTP.Port := 587;
    TppSMTPIndy(lEmail.SMTP).IndySMTP.AuthType := satSASL;
    TppSMTPIndy(lEmail.SMTP).IndySMTP.IOHandler :=
    IdSSLIOHandlerSocketOpenSSL1;
    TppSMTPIndy(lEmail.SMTP).IndySMTP.UseTLS := utUseExplicitTLS;
    TppSMTPIndy(lEmail.SMTP).OnEmailError := EmailErrorEvent;

    Possible values for AuthType are
    atNone No authentication is required.
    atSASL SASL authentication is required.
    atDefault Use the default username and password authentication

    Possible values for UseTLS are
    utNoTLSSupport
    utUseExplicitTLS
    utUseImplicitTLS
    utUseRequireTLS

    I've tried countless options (I'm shooting into the dark here) and half the
    time the program freezes, the other half it processes for a bit and gives
    control back to the user.

    I was able to get a response back from google under a few configurations.
    The EmailErrorEvent returned

    mx.google.com at your service, [68.0.147.35]
    SIZE 35651584
    8BITMIME
    STARTTLS
    ENHANCEDSTATUSCODES
    PIPELINING

    Which doesn't look like an error at all.

    Another thing I've noticed is that I can place obvious errors in my login
    information and no errors are reported. Like it's not getting connected at
    all.

    I feel like I'm so close, I just can't get much information back from the
    program when it fails. What could possibly be going on here?

    I appreciate your time guys. Thanks a lot
    Dusten
    Frontline Software Technology, Inc.



  • edited April 2010
    Hi Dusten,

    Ok, finally got this working on my machine.

    The key is having the correct OpenSSL DLL libraries installed on your
    machine. You can download the latest from the following website...

    http://indy.fulgan.com/SSL/

    Below is the code I used to connect the RB Indy plugin to Gmail. I also
    wrote a Wiki article for future reference...

    http://www.digital-metaphors.com/rbWiki/Output/Email/How_To...Customize_Indy_Email_Settings

    var
    lEmail: TppEmail;
    lIOHandler: TIdSSLIOHandlerSocketOpenSSL;
    begin

    lEmail := TppEmail(ppReport1.Email);

    lIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(Self);

    try
    lIOHandler.Destination := 'smtp.gmail.com:587';
    lIOHandler.Host := 'smtp.gmail.com';
    lIOHandler.Port := 587;

    TppSMTPIndy(lEmail.SMTP).IndySMTP.Port := 587;
    TppSMTPIndy(lEmail.SMTP).IndySMTP.IOHandler := lIOHandler;
    TppSMTPIndy(lEmail.SMTP).IndySMTP.UseTLS := utUseExplicitTLS;

    ppReport1.SendMail;

    finally
    lIOHandler.Free;
    end;
    end;

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2010
    Thank you very much Nico! That worked for me.

    Dusten Scheere
    Frontline Software Technology, Inc.

This discussion has been closed.