Click here to Skip to main content
6,595,854 members and growing! (17,801 online)
Email Password   helpLost your password?
General Programming » Internet / Network » Email & SMTP     Beginner License: The Code Project Open License (CPOL)

Digitally Signing Emails

By Dan Madden

Digitally signing Emails using CAPICOM and CDO
C# 2.0, .NET (.NET 2.0), WinXP, Dev
Posted:29 Mar 2008
Views:5,555
Bookmarked:10 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
1 vote for this article.
Popularity: 0.00 Rating: 1.00 out of 5
1 vote, 100.0%
1

2

3

4

5

Introduction

As this is my first time using C#, I thought that migrating something to C# would be the best for me to learn. Well, I happen to pick something that although portions are on the Internet, the full monte was not unless you want to pay money for it (and the code): grr. So putting it all together became the next task.

Background

I searched The Code Project first and found a useful CAPICOM class wrapper. Now I just needed to see some C# examples on sending Emails via CDO. Well there was a whole lot of that out there, so I sat down and began putting this all together.

Using the Code

I tried to make it as simple as possible (mainly because I was learning as I did it), but to use it, simply reference the DigSigs.dll in your project and do what I did below (maybe add some tags to the HTMLBody if you use it), compile it and execute it. You could do a lot more with this from a console or GUI and make it much better than it is at this point, so I will leave it to you ... enjoy!

using System;
using System.Collections.Generic;
using System.Text;

namespace DSEMails
{
    class Program
    {
        static void Main(string[] args)
        {
            DigSigs.CDOEmailer email = new DigSigs.CDOEmailer();
            //
            email.To = "email address";
            email.From = "email address";
            email.CC = "email address";
            email.Signature = "name of signature";
            email.Subject = "Digital Signing Test";
            email.TheStore = "My";
            email.SMTPServer = "SMTP Server or IP Address";
            email.Body = "This is the BODY of the message!!";
            email.HTMLBody = "This is the BODY of the message!!";
            //
            email.SMTPPort = 25;           // Default Value
            email.Important = 2;           // Default Value
            email.PlainText = false;       // Default Value
            email.TimeOut = 120;           // Default Value
            email.UseMachineStore = false; // Default Value
            email.Debug = true;            // Default Value
            //
            if (email.SendTo())
            { Console.WriteLine("\nSigned and sent...\n"); }
            else
            { Console.WriteLine("\nError: Failed to send email?\n"); }
        }
    }
}

There are two classes:

  • DigSigs.CAPIWrap() which does all the signing
  • DigSigs.CDOEmailer() that is used to send the Emails

Other CodeProject Sources

As I mentioned earlier, I had help from a member of CodeProject because he had written an article about CAPICOM called CAPICOM class wrapper. Although I made a few modifications, this saved me a whole lot of time and I thank him for that!

History

  • 3/28/2008 - Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Dan Madden


Member
I have been programming for 19 years (Unix C, Scripting, VB, C/C++, C#). I am getting too old to talk about it and been in the Security line of work (both Military/Civilian) for 25+ years.
Occupation: Engineer
Location: Germany Germany

Other popular Internet / Network articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
GeneralError PinmemberAzeem Yaseen21:43 9 Apr '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 29 Mar 2008
Editor: Deeksha Shenoy
Copyright 2008 by Dan Madden
Everything else Copyright © CodeProject, 1999-2009
Web15 | Advertise on the Code Project