Premiere & Nettalk - add BCC adddress in report and customize PremiereGetData window for emails

I have a custom application for Voluntary Associations which among others is sending statutory notes for membership fees and other documents to members. Customer would like to be able to specify CC/BCC addresses to deliver a copy of these to specific preople dealing with members’ affairs.Other reports generated by the app should not be BCC’d

How do I specify BCC address in the report procedure ?
I cannot find BCC address in PremierePreviewerOptions Group, in EmailParametersGroup this variable exists and I can specify it when calling SendEmail procedure manually. I was trying to use UserData StringTheory object, but cant’t figure out how to refer to it in SendEmail or Premiere procedures.

Can I call custom GetData window when sending email via Premiere previewer?
Ideally for sending emails I would display all header fields (from, cc, bcc, subject) and message text as well, allowing user to add custom text to the email if needed.

so it’s probably best to break this down into two problems;

a) collect the data to use
b) use the data when sending the email.

the second one is easier, so let’s deal with that first;
Sending mails flows through the SendEmail method, into which the tempalte generates a call to your SendEmail procedure. So you can embed in the Premier procedure, in the SendEmail method, before the call to your SendEmail procedure. You can populate the various EmailParametersGroup fields here. So passing the CC and BCC to SendEmail procedure is easy.

The first problem is slightly more complex. The PremierGetData procedure in your app is used by the class to get various different bits of data. It’s currently limited to 2 items of data, but you could extended it (by adding more optional parameters and adding a bit more functionality to the window and the andding code to support those - search for pWhat2 in the generated code and you can add pWhat3 and so on.

Once PremierGetData is extended (or perhaps, if you like, a second copy of the procedure is created, and then extended, then you need to call it correctly, at the appropriate time. As before this procedure is called from the Premier proceure, in the (cunningly named) GetData method. You can inspect the pWhat parameter to know when to intercept (‘To Email Address’) and then store the results in local variables (which you would then use in the SendEmail method.)

So yes it’s all possible with just a few lines of embed code in the Premier procedure, and an extension of the behaviour in PremierGetData.


Hi Bruce

I know I can embed in the Premiere procedure, in the SendEmail method, but what I need is to be able to set BCC value in the Report procedure calling Premiere previewer not in Premiere itself as I only want to send a BCC copy of a specific reports, not all of them. I’m trying to use UserData parameter, which does not fully work as expected.

In SetPremiereOptions embed in my report procedure I set UserData object as mentioned in the docs

UserData.SetValue(INIMgr.Fetch('Defaults','DefaultEmailBCC'))   ! An example, 
! in fact this value is report specific
PreviewParms.UserData &= UserData

Collecting data turned out to be quite simple, although I’m not sure if this is the best place to call this procedure. But seems to work.
I created a window procedure to allow user to modify email parameters

WinEmailGetData PROCEDURE (*String pSuggestionTo, |
*String pSuggestionBcc,*String pSuggestionSubj,*String | 
pSuggestionText,*String pSuggestionHtml)

which displays all above fields and allows to modify their values
in in Premiere procedure added below before premiere init, to disable calling your GetData procedure first

ThisPremiere.PreviewParms.PreventEmailChange = 1

and call mine instead

ThisPremiere.SendEmail   PROCEDURE (EmailParametersGroup pEmail)
ReturnValue   Long
  pEmail.pEmailBcc = pEmail.pUserData.GetValue()   ! This throws exception
!  if value not set in the report procedure
  IF WinEmailGetData(pEmail.pEmailTo,pEmail.pEmailBcc, |
pEmail.pEmailMessageHtml) = TRUE
  Return SendEmail(pEmail) ! turn off option on Preview window, extension template, if there is no SendEmail procedure
  ReturnValue = PARENT.SendEmail (pEmail)
  Return ReturnValue

However, when I call premiere previewer from other reports that do not need to be emailed and therefore UserData object value was not set I get

Exception occurred at address 00DCB89E
Exception code C0000005: Access Violation


How can I check within Premiere procedure if the UserData object value was set ?

And what is the difference between GetValuePtr() and GetValue() - they both seem to return the value of the object if it’s set and crash if it’s not. The docs say to use GetValuePtr() rather than value property directly, but do not say why.



you should wrap this in a test;

if not  pEmail.pUserData &= null
  pEmail.pEmailBcc = pEmail.pUserData.GetValue()   ! This throws exception
!  if value not set in the report procedure

GetValuePtr returns a pointer to the string, and is used in cases where the value is being passed to something that takes a *string parameter. GetValue can be used when passing to something that takes a string, or when assigning a value.

Thanks. That helped.