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