LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SMTP Error after Building EXE

After working on this for a few hours, I give up. I'm trying to send an email when an item errors. I am able to get my code to run fine when it's a VI, but when it's an EXE, I get the following error:

Error calling method System.Net.Mail.SmtpClient.Send of ObjectId handle: 0xA971168 for obj 0x30E9943[System.Net.Mail.SmtpClient] in domain [Application.exe for Run] and thread 8748, (System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 Inner Exception: System.Net.Mail.SmtpException: Failure sending mail.
 Inner Exception: System.Net.WebException: Unable to connect to the remote server
 Inner Exception: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 10.80.4.119:25
) in testEmailVI.vi

I've traced the issues to SMTP Client Send. Any ideas of what might be going wrong? I'm including my project and exe.

Thanks in advance!!

0 Kudos
Message 1 of 7
(3,449 Views)

Firewall permissions for your .exe?

0 Kudos
Message 2 of 7
(3,448 Views)

@Ravens Fan wrote:

Firewall permissions for your .exe?


That's what I was thinking.  Check with IT.  It might be blocking your e-mail, because it is sourced from an .exe.  I had a similar issue when our IT department enabled some SPAM feature.  I resorted to using G-mail instead.  I haven't had an issue since.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 3 of 7
(3,445 Views)

Thanks for the replies! I'll check in with my IT department.

0 Kudos
Message 4 of 7
(3,434 Views)

Are there any special settings/permissions required when you build a SMTP VI? I'm currently trying to build the GmailLV86 VI in a project. Again, everything works when I use a VI, but once I build it I get:

Error calling method System.Net.Mail.SmtpClient.Send of ObjectId handle: 0xA1D1150 for obj 0x30E9943[System.Net.Mail.SmtpClient] in domain [Application.exe for Run] and thread 7392, (System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 Inner Exception: System.Net.Mail.SmtpException: Failure sending mail.
 Inner Exception: System.Net.WebException: Unable to connect to the remote server
 Inner Exception: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 173.194.77.109:587
) in GmailLV86.vi

 

I'm currently working remotely not on VPN onto my workplace network. I guess it could still be a setting on my computer?

0 Kudos
Message 5 of 7
(3,428 Views)

As already mentioned you have to allow TCP access for you application in the Windows Firewall (or whatever you use in it's place). By default Windows Firewall blocks all network access for an executable and should show a dialog the first time you run the executable. If you happen to be a fast clicker who dismisses any and all dialog boxes without really reading them you easily can end up telling Windows Firewall to block your executable from accessing the network.

 

It doesn't matter if you do the network communication through .Net, WinSockets or whatever else network API, as the Firewall hooks into the lowest level socket interface and blocks based on executable, not used interface.

Rolf Kalbermatter
My Blog
Message 6 of 7
(3,421 Views)

You've already setup a G-mail account, correct?  Check to make sure your username and password are correct.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 7 of 7
(3,411 Views)