Welcome, Guest
Username: Password: Remember me
Share your code snippets, screen shots etc. here
  • Page:
  • 1

TOPIC:

How to enhance your VO application with X# - the SendMail DLL 06 Aug 2017 15:19 #2302

  • wriedmann
  • wriedmann's Avatar
  • Topic Author


  • Posts: 3367
  • Often some things are hard or impossible to accomplish in VO applications, but easy in X# applications because the .NET framework has the required functionalities.

    One of the VO shortcomings is the possibility to send mail through GMail: SSL is required and the VO cSMTP classes cannot use SSL because the Windows API seems to not have the needed functionality.

    Therefore I created a simple X# DLL, named SendMail.DLL that exposes a class interface ISmtpSender through COM and use this DLL in my VO applications.

    You can find this DLL together with a VO sample application and the relative source code in XIDE export format attached to this message.

    Of course you can enhance this DLL as needed, but please generate a new SNK file and new GUIDs for your own version. I'm using exactly this DLL in several of my applications.

    The DLL must be located in the directory of the executable, otherwise SideBySide will not work.

    The entire mechanism is a bit unstable until you understand how this works: it is a game between the COM interface of the DLL, the DLL manifest (generated by mt.exe) and the manifest of the executable. And please pay particular attention to the version info: they must match!

    This is the content of the readme in the DLL source code:
    1) create key file with 
    sn - k sendmail.snk
    2) after building and signing the DLL, read the public key with
    sn -T sendmail.dll
    (upper case T)
    3) create the TLB with elevated rights
    regasm sendmail.dll /tlb
    4) remove the registration
    regasm sendmail.dll /unregister                                                  
    5) create the automation server in VO
    6) add cClsID and cProdId in the Init method
    7) create the manifest for the DLL
    mt.exe -managedassemblyname:sendmail.dll -nodependency -out:sendmail.dll.manifest  
    8) adjust the manifest (remove "msil" and add "win32")
    
    Caveats:
    - the namespace should be set also in the DLL properties, can be identical to the DLL file name
    - the class CANNOT have the same name as the DLL 
    
    Debugging (if the VO application does not starts):
    sxstrace Trace -logfile:systrace.out
    sxstrace Parse -logfile:systrace.out -outfile:sxstrace.txt
    notepad sxstrace.txt

    Happy mailing!

    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it
    Attachments:

    Please Log in or Create an account to join the conversation.

    Last edit: by wriedmann.

    How to enhance your VO application with X# - the SendMail DLL 17 Aug 2017 18:48 #2412

    • wriedmann
    • wriedmann's Avatar
    • Topic Author


  • Posts: 3367
  • A few days after posting this sample, I have received a email with the following text (quoting only the important part):

    I started the tests and achieved the following results.

    For mailserver without SSL, the email is sent without any problem.

    For SSL mailserver:
    Smtp.gmail.com
    Port: 587
    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
    Note: Login and Password are entered correctly.
    Port: 465
    Failure sending mail.

    Smtp.abv.bg
    Failure sending mail.

    Smtp.live.com
    The e-mail is sent without any problem.

    I want to ask if the problem is in the servers or I have not done the right thing.


    I have answered as follows:

    with gmail my sample works, I have tested it. But to have SMTP working with GMail, you have to enable „less secure applications“ in the web interface. Otherwise Google requires an authentication type that is nearly impossible to implement.

    For the other SMTP servers I cannot say anything as I don’t know the specifics.
    Unfortunately there are two possible SMTP SSL types: TLS and SMTPS (mostly over port 465).

    The .NET classes unfortunately support only TLS. Please see here for more informations:

    msdn.microsoft.com/en-us/library/system....lessl(v=vs.110).aspx

    So because of this my sample cannot support SMTPS like no other software based on the .NET Framework classes can do this.

    Maybe Microsoft later decides to support it, or maybe someone releases a free implementation (but I have my doubts).


    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    How to enhance your VO application with X# - the SendMail DLL 18 Aug 2021 12:03 #19386

    • wriedmann
    • wriedmann's Avatar
    • Topic Author


  • Posts: 3367
  • Hello for who is interested,
    I have now found an issue: the compile of the sendmail.dll works only if you have Vulcan.NET installed on your machine. Otherwise the needed manifest is not correctly embedded into the DLL.
    Do make it work, the content of the file Manifest.CREATEPROCESS_MANIFEST_RESOURCE_ID.rc has to be changed from
    CREATEPROCESS_MANIFEST_RESOURCE_ID RC_RT_MANIFEST "SendMail.manifest"
    to
    #define RC_RT_MANIFEST 24
    CREATEPROCESS_MANIFEST_RESOURCE_ID RC_RT_MANIFEST "SendMail.manifest"
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1