Home General

Emailing a report/PDF attachment

edited May 2007 in General
Hi,

I'm adding the ability to e-mail reports from our software using the e-mail
facility built into reportbuilder.

When I click the transmit button that fires off the sendmail command I'm
prompted by a delay message from Windows/Outlook warning something is trying
to send mail automatically with the options to click yes/no etc.

I've had this using another unrelated e-mail component but it isn't a
problem so I've not had to investigate so far.

Is there any way of turning this off?

Thanks,

Jeff

Comments

  • edited May 2007
    Hi Jeff,

    What you are seeing is Microsoft's solution to prevent malicious software
    from taking control over their email software and using it to send mass
    emails/viruses etc. This was added for Windows XP SP2 and for Outlook 2003
    and unfortunately it is not possible to disable the warnings.

    There are two workarounds/options.

    1. You can set the EmailSettings.PreviewInEmailClient property to True.
    This will open an outlook window when an email is sent. It requires the
    user to send the email from that dialog again but at least there are no
    warnings or messages.

    2. You can use the Indy plugin to bypass any email clients on your users'
    machines. The indy plugin will directly connect to an email server and send
    the email silently. An example of using the Indy plugin is available in the
    main reports demo (demo 109).

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2007
    Hi Nico,

    Thanks for the info.
    Further discussions here; we believe it might only affect clients of an
    exchange server but it's not been tested yet.

    After implimenting as is I may have to try the indy client.

    Thanks again,

    Jeff


  • edited May 2007
    Hello,

    if there is an Exchangeserver at the backend, you can install a template and
    disable the warning.
    The link below is german, but there are links to the Registry which can
    help.Also you need an adminpack.
    http://www.eulanda.de/inside/bedienerhandbuch/zubehoer/outlook/sicherheit.htm


    The only other way i know is, to use Extended Mapi which has no
    scriptinterface. A dutch company has a vcl for this.
    http://www.rapware.nl/prod_easymapi_page1.asp?SubMenu=EasyMAPI


    --
    best regards
    chris (EULANDA)

    www.eulanda.com
    ERP SOLUTIONS
  • edited May 2007
    You could use ClickYes from Context Magic. We find this the ideal solution
    because the mail is sent using the users Outlook profile and will appear in
    the sent items of the mailbox, as well as going via the Exchange server if
    they have one meaning you have all the logs and tracking that entails too.
    Using Indy etc. works fine, but doesn't give you any of that (unless you
    write it too!).

    Context Magic have a free version and a pro version - the pro version is
    well worth it since it allows you to specify which applications are allowed
    to "shortcut" the Outlook security model. Our clients who do large mailings
    using our aplications will vouch for it!

    Mike Combellack
    Software Experts S.L.


  • edited May 2007
    Hi,

    After testing using this method it sends the e-mail fine BUT it sends using
    all the credentials of the mail client even though I provide it with all the
    settings necessary to send.

    Code:
    EmailSettings.FromName:= gFromName;
    EmailSettings.FromAddress:= gFromAddress;
    EmailSettings.HostAddress:= gHostAddress;
    EmailSettings.Username:= gLoginName;
    EmailSettings.Password:= gLoginPassword;
    EmailSettings.ReplyTo:= gReplyToAddress;
    EmailSettings.Subject:= 'Email Order: '+IntToStr(OrdNo);
    EmailSettings.Recipients.add('XXX@YYY.COM');

    /Code

    The Variables are all populated correctly for a test account on a different
    smtp server.
    However when I call Sendmail it still uses my work details and the received
    e-mail appears to be from my work account.

    I've tried changing my default e-mail client from Outlook to Outlook express
    where I don't any e-mail accounts set up - I'm prompted to create one; which
    I've done using dummy data - the e-mail attempts to be sent using the dummy
    data again instead of using those I've provided.

    Any suggestions as to what I've missed or misunderstood?

    Thanks,

    Jeff



  • edited May 2007
    Hi Jeff,

    Which plugin are you using, MAPI, Outlook or Indy? Also which version of
    ReportBuilder do you currently have installed?

    Looking at your settings below...

    1. If you are using MAPI, the UserName defines which profile you should use
    to send the email with. Leaving this property blank will use the default
    profile.

    2. If you are using MAPI or Outlook, there is no need to assign the Host
    Address.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2007
    Hi Nico,

    I'm using RB v.10.04

    I've only just managed to get the demo working so I've only just seen that I
    have to use the : TppSMTPPlugIn.RegisterClass(TppSMTPIndy); code.

    Using the demo I was unable to use the test button error 10052 but it looks
    like it might be out Virus scanner stopping it...
    It's killed now and the test shows as successful but it's just hung after
    clicking send.

    Hopefully it will work now.

    I'm sorry I didn't realise I needed to tell it to use the indy client so by
    default it was using MAPI.
    O well, lets hope this works.

    Thanks again,

    Jeff

    p.s. WOW it just worked...
    I know it's lazy to ask but is there a way to check if the mail has been
    sent? I had a quick look through the help section but didn't see anything.



  • edited May 2007
    Hi Jeff,

    You can use the TppSMTPCustom.Status property to check the current status of
    an email being sent. This can be accessed directly from the TppEmail object
    or from the report using the TppReport.Email property.

    uses
    ppEmail;

    CurrentStatus := TppEmail(Report.Email).SMTP.Status;

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2007
    Hi Nico,

    I've added ppEmail in the USES section and the following lines into the
    code.

    CurrentStatus :=
    TppEmail(PoReportDml.rptPurchseOrderPortrait).SMTP.Status;
    CurrentStatus2 :=
    TppEmail(PoReportDml.rptPurchseOrderPortrait.Email).SMTP.Status;

    CurrentStatus always shows as '' (it's a string). I created CurrentStatus2
    because I couldn't access .email and it still doesn't allow me to use it.

    Am I missing something here? I am fairly new to Delphi Development so it's
    quite likely I've misunderstood what you meant.

    Thanks,

    Jeff

  • edited May 2007
    Hi Jeff,

    Where are you assigning the CurrentStatus variable? I would recommend
    implementing the OnStatusChange event which will fire each time the status
    text is altered.

    Note: In your first line of code, you are typecasting the TppReport as a
    TppEmail object which will either fail or give you unwanted results. The
    Email property of a TppReport object is declaired as a TObject to avoid
    circular references so it is necessary to typecast is as a TppEmail object.
    If it helps, try splitting it up in code a bit...

    var
    lEmail: TppEmail;
    begin

    lEmail := TppEmail(ppReport1.Email);
    lEmail.SMTP.OnStatusChange := StatusChangeEvent;

    end;

    procedure StatusChangeEvent(Sender: TObject);
    var
    lEmail: TppEmail;
    begin

    lEmail := TppEmail(ppReport1.Email);
    CurrentStatus := lEmail.SMTP.Status;

    end;

    --
    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.