Bitspan provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Bitspan support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Bitspan Certified Partner or the Bitspan fee-based consulting line at (604) 926-3242. For more information about Bitspan Certified Partners, please visit the following Bitspan Web site:
http://www.bitspan.com/partner/referral/
For more information about the support options that are available and about how to contact Bitspan, visit the following Bitspan Web site:
Automation (formerly OLE Automation) allows one program to control another program by either issuing commands or retrieving information programmatically.
The Bitspan Spamity™ Agent Object Model
Check to see if an email is spam or not:
//Sample code for calling IsSpam function
using System;
using System.Runtime.InteropServices;
namespace CSpamCsSample
{
class Class1
{
//
// Copy "Spamity.dll" to "c:\" or alter the path as necessary
//
[DllImport("C:\\Spamity.dll")]
public static extern int UpdateDefinitions(int nThreadMode);
[DllImport("C:\\Spamity.dll")]
public static extern int IsSpam (string body, string sTo, string sCC, string sFrom, string sReplyTo, string sIP, ref int nDefNum);
[DllImport("C:\\Spamity.dll")]
public static extern int GetStat (ref int ndef, ref int nomi, ref int nomIP);
[DllImport("C:\\Spamity.dll")]
public static extern int SetKey (string key);
[DllImport("C:\\Spamity.dll")]
public static extern int Terminate();
[STAThread]
static void Main(string[] args)
{
int DefNum = 0;
//
// Set the license key
//
// << IMPORTANT NOTE >>
// YOU NEED A LICENSE KEY FROM BITSPAN TO GET THE LATEST DEFINITIONS
// YOU CAN GET A TRIAL KEY BY VISITING http://www.bitspan.com/spamity
SetKey("LICENCE KEY GOES HERE");
//
// The first time UpdateDefinitions function is called, it may take a few
// minutes to return. It should take shorter time to return once the definitions are
// cached and stored locally.
// After that you can call IsSpam function against your emails.
// Updates will be downloaded automatically and will not affect
// the IsSpam processing time.
UpdateDefinitions(1);
// To do: Replace "Email body" with the body of your email.
// Change "to", "cc", "from", "replyto" parameters with
// the corresponding values from your email. The latest
// parameters are optional, but you can get a more accurate
// result by using them.
// Check whether an email is spam or not
long result = IsSpam("body","to","cc","from","replyto",null,ref DefNum);
// Check results of IsSpam function call
if(result != 0) System.Console.WriteLine("\nThe email was spam");
else System.Console.WriteLine("\nThe email was Legitimate");
// For having a graceful termination/clean up, it is better to call Terminate().
Terminate();
}
}
}
For more information about creating solutions with Bitspan Spamityä, please see the following articles in the Bitspan Knowledge Base:
100001
How to Automated Bitspan Spamity™ Agent from
Visual Basic
100003 How to Automated Bitspan Spamity™ Agent from
SOAP/HTTP
|
Last Reviewed: |
5/05/2005 (1.0) |
|
Keywords: |
kbdtacode kbhowto kbProgramming kbusage KB100007 |