Forum Discussion

Joshua_Bowden's avatar
Joshua_Bowden
Ideator I
4 years ago
Solved

Send emails from a C# Method not working

Hello,

I am trying to send an email from within a C# method but I am not receiving the message in my email. My code is made up of trying to check a url and then return if the url returned with an OK status or a 404 Error. When I get to the part where I want to send the email to myself it runs the code but I do not receive the message. Below is a snippet of my code. The result boolean value is returning true. Any idea what could be wrong?

Item fromUser = this.newItem("User", "get");
fromUser.setProperty("login_name", "admin");
fromUser = fromUser.apply();

//Get email message
Item email_msg = this.newItem("EMail Message", "get");
email_msg.setProperty("name", "ARAS Job Scheduler");
email_msg = email_msg.apply();

email_msg.setProperty("subject", "Series Website Check " + DateTime.Now.ToString());
email_msg.setProperty("body_plain", messageBody);
email_msg.setPropertyItem("from_user", fromUser);

//Get admin Identity

Item iden = this.newItem("Identity", "get");
iden.setProperty("name", "Joshua Bowden");
iden = iden.apply();

//return inn.newError(email_msg.ToString());

bool result = this.email(email_msg, iden);

  • 1. Does your User item contain the required email address?

    A: My user has the correct company email address.

    2. Do you have checked your Spam folder?

    A: Nothing in there.

    3. Does your Email Message items contains the correct "From User"?

    A: We are using the default Innovator Admin user.

    ***Solution***

    I switched the "From User" to myself and I was able to receive the email. I am assuming that it was not working because the Innovator Admin user did not have an email registered to it.

6 Replies

  • Also, I am planning on running this through the Job Scheduler so to test this method I am using the "Run Server Method" Action.

    • AngelaIp's avatar
      AngelaIp
      Ideator I

      Have you ever sent any emails from your Innovator at all, e.g. via LifeCycle messages?

      Have you specified your email service in the server config files?

      It´s not surprising your code returns a 'true' result. But with the default settings, your emails just will end up as text files in the temp folder in your codetree.

      • Joshua_Bowden's avatar
        Joshua_Bowden
        Ideator I

        We are not incorporating Lifecycles in our current system due to issues we had in the past with them but I have used the email notification on a workflow which works perfectly fine sending me an email. I also checked the server config files and everything seems to match what was discussed in other threads. I read in another thread that it might go to the Innovator/Server/temp folder but I do not see the text files in there either.