Jump to content

Error:You must call EmailCreate before calling this function.


milanm
 Share

This topic is 2890 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I created a script to perform on the server and send an HTML email.

The server is Windows 2008 with FileMaker 13 Server and i installed the 360Works Email plugin 64 bit version on it.

First script steps work fine:

- it by-passes the opening script

- it finds the correct layout and record where the email parts are stored - body, from, to, subject - as a list from which the corresponding variables are created: $from, $to, $subject and the body field called PSOS_Emai_body is used in the script later as a field.

- It checks if the plugin is installed with no error

- it register the plugin with no error (Developer license)

- it connects to the SMTP server with no error

- than it runs the script that is supposed to prepare the message to be sent:

 

Set Variable [ $result =

     EmailCreate( $from ; $to ; $subject ) and

     EmailSetBody( PSOS_Email_body ; "html" ) and 

If (Message::contentType  ≠ "plain" ;
    EmailSetBody( Message::body ; "plain" ) ;  /* include a plain-text version of the message for clients which can't read HTML email */
    True /* message is already plain-text */

 ]

 

- finally it runs the log script and the Emailsend script that is supposed to log the result send the email as suggested in the sample files from 360Works given with the plugin:

Set Variable [ $result =

     EmailSend

 ]

 

A couple of times it returned a nice html email as expected.

Than suddenly it started returning the error after Emailsend script: "You must call EmailCreate before calling this function."

 

I know that this function is called previously, and it also worked a few times as is, so this is very confusing.

Could you please help me resolve this and send my emails from the server.

 

Link to comment
Share on other sites

Are your EmailCreate and EmailSend scripts in separate scripts? If so and you're calling them in separate Perform Script on Server calls (that is, Perform Script on Server("EmailCreate") followed by Perform Script on Server("EmailSend")), you'd get this situation, because each PSOS call is a separate plugin context and nothing is held in memory between them. Additionally, the Connect steps (SMTP, IMAP, or POP) clear out the current message, so be sure to call any of those before EmailCreate. 

 

If none of that helps, I think we'd need to see our plugin logs, which you can find in your FileMaker Server/Logs/ directory.

Link to comment
Share on other sites

Hi,

yes the EmailCreate and EmailSend functions where in the separate script. I troubleshooted the script with some support from 360Works and we managed to make it work finally.

What happens is that "EmailCreate" function fails if any of its part is not precisely defined. In this case i thought that i could use a 2 word description in the "from" feature but it seams that it has to be an email address. The plugin process would check this feature, recognise that it is not correct and cancel the function like it was never called. As the "EmailSend" function was triggered a few steps later after the logging script step (like in the demo files) it was unable to find the cancelled "EmailCreate" function and would log the error from the title: "You must call EmailCreate before calling this function".

 

When i placed the "EmailSend" function inside the same script step as "EmailCreate" it came up with some other errors (@ missing, blank space) and finally we where able to trace it to the "from" part of "EmailCreate" function.

 

Now it works just fine, hope this helps somebody resolve the error faster.

Link to comment
Share on other sites

Great, I'm glad to hear you figured it out! 

 

On another note, thanks for updating this thread with the solution! We're all too familiar with searching for a solution to a problem and finding a thread with our exact problem with the last reply being: "I figured it out thanks" with no explanation. I wish every error thread could resolve as well as this one :)

Link to comment
Share on other sites

This topic is 2890 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.