visual c++, calling a c# class to access e-mail account via pop, imap and smtp RRS feed

  • Question

  • Here is code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Lesnikowski.Client;
    using Lesnikowski.Client.IMAP;
    using Lesnikowski.Mail;
    using Lesnikowski.Mail.Fluent;
    using Lesnikowski.Mail.Headers;
    using Lesnikowski.Mail.Headers.Constants;

    namespace Email
        public class Class1
           public void POP3_Subject_Message(String User, String Password,String Server)
              Pop3 pop3 = new Pop3();
              pop3.User = User;
              pop3.Password = Password;
              SimpleMailMessageBuilder builder = new SimpleMailMessageBuilder();
              for (int i = 1; i <= pop3.MessageCount; i++)
              { ISimpleMailMessage mail = builder.CreateFromEml(pop3.GetMessage(i));

           public void IMAP_Subject_Message(String User, String Password, String Server)
               Imap imap = new Imap();

               imap.User = User;
               imap.Password = Password;

               List<long> uidList = imap.SearchFlag(Flag.Unseen);
               foreach (long uid in uidList)
                   ISimpleMailMessage mail = new SimpleMailMessageBuilder()

           public void SMTP_Send_Message(String User, String Password, String Server)
               ISimpleMailMessage message = Mail
               .Html(@"Html with an image: <img src=""cid:lena"" />")
               Smtp smtp = new Smtp();
               smtp.Ehlo(HeloType.EhloHelo, "yourname");

               smtp.User = User;
               smtp.Password = Password;



    c++ code to call it:

    #using "Email.dll"
    using namespace Email;

    int main()
       Class1 Object1;

    It suppose to access my gmail account to view e-mail messages vis pop server. I enable pop server in settings in my gmail account.
    When I run I get exception error,

    All the credentials are correct. Can someone tell me what is wrong with c# class,
    what should be changed or modified?

    Thanks in advance, Gennady46


    Thursday, February 4, 2010 3:55 AM


All replies

  • This is a Visual C++ Language forum. Your question completely OT here.
    Thursday, February 4, 2010 4:22 AM
  • I see you have edited your original post, adding a little C++ client code. Are you hoping this makes your question more relevant to this forum?
    Thursday, February 4, 2010 4:36 PM
  • what was the exception message?, As per yor code you are missing port number. Some webmail servers commuicate via diffrent servers, some may enabled SSL too. You have to check that with Gmail Pop3 settings.
    Thanks Mike --------Please mark as answer if it is useful----------
    Thursday, February 4, 2010 4:58 PM
  • The error is: The exception unknown software exception (0xe0434f4d) occured in the application at location 0x7c812afb.

    Do you think I am missing a port number? I checked with pop I did not see a port ssl. If you would ad port # what is code for that for pop3?

    Thanks gennady46
    Thursday, February 4, 2010 7:40 PM
  • here is a good article on this http://www.codeproject.com/KB/cs/karavaev_denis.aspx .
    Thanks Mike --------Please mark as answer if it is useful----------
    • Marked as answer by Gennady46 Friday, February 5, 2010 7:35 PM
    Friday, February 5, 2010 11:33 AM
  • Since the majority of your code is C# and that is where the error is originating, you really should ask there.
    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    Friday, February 5, 2010 1:12 PM