Sign on Save

Hello,
Like similar save options in Words do you have save options to Sign only (NO encrypt) emails on save?

We have certificate with private key in a X509Certificate2.

Needed for Eml/Emlx and Msg/Oft/Tnef to sign on save.
Thanks for advise :slight_smile:

Hello, you can use the AttachSignature(X509Certificate2) method of MailMessage and then call the Save method.

1 Like

Hello and thanks, what’s the difference between this and MailMessage.Sign?
Also AttachSignature will work for MapiMessage?
Best :slight_smile:

MailMessage.Sign, I’m not sure I know about this. Anyway, we’ll see on Monday.

1 Like

Sorry, my confusion, just one thing, there’s no MapiMessage.AttachSignature counterpart :frowning:
Hopefully there is a way to sign a MapiMessage using X509Certificate2 pfx?
Thanks :slight_smile:

Hi @australian.dev.nerds
You can sign MapiMessage if you convert it to MailMessage. Then you can save it in eml format or msg format.

So we cannot sign MapiMessage, since converting it to MailMessage will remove many Mapi properties.
May I ask a feature request ticket for adding MapiMessage.AttachSignature?

Hi @australian.dev.nerds

We will discuss this request with our project manager and inform you through this thread.

1 Like

Thank you very much, highly appreciated :slight_smile:

Btw, if there’s a way to select between sha256, sha384 and sha512 when s/mime signing of emails, please kindly advise?

Hi @australian.dev.nerds

You can use public virtual MailMessage AttachSignature(CmsSigner signer) method with
previously created a CmsSigner with the necessary parameters like this:

MailMessage msg = MailMessage.Load("d:\msg.eml");
X509Certificate2 certificate = new X509Certificate2("d:\cert.pfx", "password");
CmsSigner signer = new CmsSigner(certificate); 
signer.DigestAlgorithm = new Oid("SHA256");//you can use SHA1,SHA256,SHA512 
MailMessage signedMsg = msg.AttachSignature(signer);
1 Like

Hello and thanks, a strange thing:
The project is fine in vs.net 2010 but won’t compile in .net 2022:

The error is only for MailMessage.AttachSignature

Error BC30652 Reference required to assembly System.Security Version=4.0.0.0 containing the type CmsSigner. Add one to your project.

System.Security is already imported.

  • Found:

Should use:
Reference Include=“System.Security”
instead of:
Import Include=“System.Security”

Hi @australian.dev.nerds
I need some time to investigation.

1 Like

@australian.dev.nerds
Some questions:
1.How you use Aspose.Email dll - from file or NuGet?
2.Which version of framework you use in vs 2022?

@australian.dev.nerds
Please try the following steps:
1.Create a new project from scratch.
2.Add a reference to Aspose.Email from Nuget.
3.Implement the code.
4.Try to compile.
If all else fails, archive the project and send it to us.

Hello there
Can you please be so kind and pull the info if the feature is approved and about its priority?
IMO I think it’s a must have to be able to sign messages for email components, as agreed, converting to/from MailMessage is useless as will remove all the MAPI properties so is destructive.
Thank you :slight_smile:

Hello,

We will inform you about it within 2-3 days.

@australian.dev.nerds
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILNET-41221

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

Thanks a thousand times, awesome feature to have :slight_smile:

You are welcome.

1 Like

Hello,
Is this already added? :slight_smile: