The C# code from that link is only intended for rare occurrences where you don't have any e-mail but have a stand-alone file and its signature (a .p7s file) instead and need to validate that.
Normally, you only need to validate a signed e-mail. In that case, all you need is the code from this tutorial:
C#
// create an instance of MailMessage
MailMessage message = new MailMessage();
// load the message from a local disk file
message.Load("c:\\message.eml");
// validate the signature if the message is signed
if (message.IsSigned)
{
MailSignatureValidity result = message.ValidateSignature();
if (result.Valid)
Console.WriteLine("The signature is valid.");
else
Console.WriteLine("The signature is not valid.");
}
else
{
Console.WriteLine("The message is not signed.");
}
VB.NET
'create an instance of MailMessage
Dim message As New MailMessage
'load the message from a local disk file
message.Load("c:\message.eml")
'validate the signature if the message is signed
If message.IsSigned Then
Dim result As MailSignatureValidity = message.ValidateSignature()
If result.Valid Then
Console.WriteLine("The signature is valid.")
Else
Console.WriteLine("The signature is not valid.")
End If
Else
Console.WriteLine("The message is not signed.")
End If