This article suggests ways for troubleshooting e-mail issues experienced on the K2.net™ 2003 Server

A number of issues may be encountered when attempting to send e-mails from K2.net™ 2003. This article suggests various actions to perform when troubleshooting these issues.

Note: K2.net™ 2003 Server uses the .NET framework to send SMTP e-mail messages to any SMTP server, regardless of product or platform.
1.  Verify that all e-mail addresses specified are valid.
  •  The "From" address may not contain any spaces and must be a valid address.
  •  If you use data/XML fields to store the address, make sure that the relevant field contains the correct data. You may use the data field viewer in the workspace to view the value stored in this field, or you may write the value to the console to verify. To write the value of the e-mail address to the console, add the following code to your server or client event, after the strEmail variable has been assigned a value (for example after the strEmail = oUser.Email statement).

C#

Console.WriteLine("email address:" + strEmail);

Visual Basic

Console.WriteLine("email address:" & strEmail)
2.  Next, start the server in console mode. as follows:
  •  Stop the K2.net™ 2003 Server service in the Services Management Console, as indicated below:
 
 
  •  Next, browse to "C:\Program Files\K2.net 2003\Bin directory" on the K2.net™ 2003 server and run (double-click) the application "K2Server.exe"
  •  You should see the server console mode appear in a window similar to the following image:
 
 
  •  Once the K2.net™ 2003 Server reaches the point in code where you inserted the Console.writeline code, the value stored in the "strEmail" variable will be written to the console as highlighted in the image below:
 
 
  •  Verify that the e-mail address written to the console exists.
  •  Once you have completed your tests, close the K2.net™ 2003 Server Console window, and start the K2.net™ 2003 Server service in the Services Management Console application.
Note: If you do not explicitly specify e-mail addresses, verify that the user you are sending the mail to, has an e-mail address in your underlying user store. If you use Microsoft® Active Directory, the user must have an e-mail address specified on the "General" tab of the user properties. To view the user’s properties under Microsoft® Active Directory, open the Active Directory Users and Computers application. Browse to the user account in question, right-click on the user name and select "Properties". The following screen will be displayed – verify the user’s e-mail address in the highlighted area.
 
3.  Verify that the correct SMTP server is being used.
During the K2.net™ installation you can specify a default SMTP server name. This value is stored in the K2Server.config file; in the "DefaultSMTPServer" element under the K2Server attribute. The "K2Server.config" file is located on the K2Server in the following directory: "C:\Program Files\K2.net 2003\Bin". Open the "K2.Server.config" file with a text editor, (for example, "notepad.exe"), and verify that the "DefaultSMTPServer" value is correct, as indicated below:
 
 
  •  If an SMTP server value is specified in a client event for a SMTP Notification Message or in a Server Mail event in the K2.net 2003™ Studio, this value will be used instead of the default SMTP server value. Verify that the value specified for the SMTP Server is correct, as indicated below:
 
 
 
  •  If no value was specified during the K2.net™ setup (which is stored in the K2Server.config file, in the DefaultSMTPServer element) or in the event itself, the .NET framework SmtpMail object, (System.Web.Mail namespace), will attempt to locate the mail exchanger from your DNS server. You can check this manually by issuing the following command from the command prompt: nslookup -type=mx <domain> (e.g. nslookup -type=mx k2workflow.com)

Inspect the output and locate the mail exchanger – this will be listed as the responsible mail addr or the mail exchanger, as in the following example:
 
 

For more information on the nslookup command in Windows XP, click here.

The .NET framework SMTPMail object will send SMTP mail to the same server as the name returned by the nslookup –type=mx command.

Note: You can also configure the Microsoft SMTP service and send mail to it. It will also send the mail to the mail exchanger, unless a smart host has been configured.
4.  Test that the SMTP server can send e-mail.

When you have established the responsible SMTP server for your domain, you can test the sending process manually. Follow these steps:
  •  Open a command prompt (Click on Start, select Run… and type cmd in the ‘Open’ textbox)
  •  Type "telnet mailservernameORipaddress 25",
e.g. telnet 172.85.65.23 25, or telnet exchsrv 25
You can use the FQDN or NetBIOS name of the server, for example:
 
 
  •  Your SMTP server should be listening on port 25, and the mail server will answer with something like:
 
 
  •  This response indicates that the server is listening on port 25 for SMTP commands.
  •  To check that the mail server is functioning correctly, type the following commands after connecting with telnet to the SMTP server as described above. Note: if you make an error issue the “RSET” command, because arrow keys, backspace, etc. send incorrect characters which may affect the result of your tests. After your test, you can disconnect with the "QUIT" command.
  •  

Type each line below, followed by enter (use valid e-mail addresses, and notice that after you supply the text for the message body, you must end with <CRLF><period><CRLF>)

helo
mail from:name@domain.com
rcpt to: name@domain.com
data
Subject:testing
hello world

 

  •  The following is an example of the result you can expect when typing the commands as described above (your input is highlighted in green for clarity)
 
 
  •  

After your final command (<CRLF>.<CRLF>), you should see a message like the following (for clarity, this message is highlighted in red in the example above)

250 2.6.0 <SCSAPDCiNKyKJWjewZk0000016b@scsapdc.sourcecode.co.za> Queued mail for delivery
  •  If you see a different message, it should indicate what the problem is, e.g. mail relaying denied. This message will assist your e-mail server administrator in identifying the problem.
    
Note: If this process does not work, and you could not send e-mail manually, then the K2.net™ 2003 Server will not be able to send e-mail either.
  •  Further details on troubleshooting Microsoft® Exchange Server relaying issues can be found at the following sites:
http://support.microsoft.com/?id=323669
http://support.microsoft.com/default.aspx?scid=kb;en-us;q289553
http://forums.msexchange.org/ultimatebb.cgi?ubb=get_topic;f=10;t=001022
  •  You could also look at the following areas to help identify your problem:
  i. IPSec policies
  ii. IP Filters on mail server or network equipment
  iii. Firewall rules
5.  Visit the web site http://www.systemwebmail.com/ for some comprehensive information on the .NET Framework class that K2.net™ uses to send e-mail messages. The site also has additional information on SMTP messaging.
6.  

It may happen that you witness intermittent errors when sending email, usually something about "transport errors". This can happen if your mail server is too busy or just not able to scale well. If that happens, try wrapping an exception handler with retry code around the smtp code. You can store the retry count and the sleep period variables in string table values, if required.

C#

for(int iErrCount = 0; iErrCount<3; iErrCount++)
{
  try
  {
    //insert smtp send code here

    //if no error is encountered, set the iErrCount to 3 to exit the loop
    iErrCount =3;
  }
  catch
  {
    //sleep the thread for 5 seconds
    System.Threading.Thread.Sleep(5000);
    if (iErrCount==2) //failed 3 times
    {
      throw;
    }
  }
}

Visual Basic

Dim iErrCount As Integer
For iErrCount = 0 To 2
   Try
    'insert smtp send code here
    'if no error is encountered, set the iErrCount to 3 to exit the loop
    iErrCount = 3
  Catch Else
    'sleep the thread for 5 seconds
    System.Threading.Thread.Sleep(5000)
    If iErrCount = 2 Then 'failed 3 times
      Throw
    End If
  End Try
Next iErrCount