LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

System_Net_Mail_SmtpClient__Create_2 Error

Solved!
Go to solution

 I am getting an runtime error -6577 (0xffffe64f) "An invalid object handle was passed to the LabWindows/CVI .NET Library" when I try to execute the following function:

 

void SendMail(void)

 {

   int iLocalFail;
   const char *caMessage;
 
  System_Net_Mail_SmtpClient smtpClientHandle;
 
  smtpClientHandle = 0;
 
  iLocalFail = System_Net_Mail_SmtpClient__Create_2(&smtpClientHandle, "smtp.us.lmco.com", 993, 0);
    
  caMessage = CDotNetGetErrorDescription (iLocalFail);
      
  CDotNetDiscardHandle(smtpClientHandle);

 }

 

Defining smtpClientHandle anyother way other than System_Net_Mail_SmtpClient causes a complier error. 

 

I am trying to use the System_Net_Mail_SmtpClient because InetSendMail is getting a "Error in sending mail" and I think our smtp server needs SSL enable.

0 Kudos
Message 1 of 5
(4,945 Views)

The following are the includes for the file.

 

#include <cvidotnet.h>
#include "System.h"
#include <cvintwrk.h>
#include "toolbox.h"
#include <formatio.h>
#include <userint.h>
#include <utility.h>
#include <ansi_c.h>
#include <gpib.h>

0 Kudos
Message 2 of 5
(4,942 Views)
Solution
Accepted by topic author Paul_Knight_Lockheed_Mart

It may be because you did not call Initialize_System to initialize the System assembly. The following does not return errors for me:

 

#include <system20.h>

void main(void)
{
 System_Net_Mail_SmtpClient client;
 int error;
 
 error = Initialize_System();
 error = System_Net_Mail_SmtpClient__Create_2(&client, "smtp-server.tx.rr.com", 25, 0);
 error = CDotNetDiscardHandle(client);
 error = Close_System();
}

Message 3 of 5
(4,923 Views)

Thanks, that fixed it.

0 Kudos
Message 4 of 5
(4,917 Views)

Does anyone has "system20.h" file that you can upload to this platform?

 

Thank you in advanced.

0 Kudos
Message 5 of 5
(1,598 Views)