Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1027101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:11:19+00:00 2026-05-16T12:11:19+00:00

I have a windows server 2008 with a mail server installed. For every emails

  • 0

I have a windows server 2008 with a mail server installed. For every emails that comes in, a C# application is launched that pipes the message through a set of optional filters and then decides whether or not to let it throught.

I have alrealdy a couple of “homemade” filters implemented but I would like to add one to take advantage of SpamAssassin’s power. Since SA is UNIX based, I’m working with its window port (SAWin32). When I launch SpammAssassin directly from command line, email gets analysed correctly:

spamassassin.exe  -L -e < C:\SPAM.MAI

(-L enables only local test, -e exits with a non zero value if the tested message was spam)

But when I try to launch it from my C# application, it doesn’t seem to work since the return value is always equal to 2 (even for ham messages):

Process proc = new Process();
proc.StartInfo.FileName = @"C:\spamassassin.exe";
proc.StartInfo.Arguments = " -L -e < C:\SPAM.MAI";
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
proc.Start();
proc.WaitForExit();
int exitCode = proc.ExitCode;
Console.WriteLine("Exit code: " + exitCode);
proc.Close();

I would like to know if there is something wrong with my code and/or if anyone has experience launching SAWin32 from a C# console application?

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:11:20+00:00Added an answer on May 16, 2026 at 12:11 pm

    After digging a while and reading Ian P’s comment, I finally got it working:

            Process p = new Process();
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.UseShellExecute = false;
    
            p.StartInfo.Arguments = @" /C C:\spamassassin.exe -e -L < C:\SPAM_TEST.MAI";
            p.StartInfo.FileName = @"C:\WINDOWS\System32\cmd.exe";
            p.OutputDataReceived += (sender, arguments) => Console.WriteLine("Received output: {0}", arguments.Data);
            p.Start();
            p.BeginOutputReadLine();
            p.WaitForExit();
            Console.WriteLine("Exit code: " + p.ExitCode);
            p.Close();
    

    The /C parameter tells CMD to carry out the command and then to terminate.

    Hope this helps someone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.