PrimalForms version: 1.1.2
OS version: Windows XP 5.1.2600 SP2
I cannot get my form to send an email out. The code is correct (I believe). I copied the code (seen below) into PrimalScript and tried running it (within PrimalScript) and I get the same error as in PrimalForms:
Exception calling "Send" with "1" argument(s): "Failure sending mail."
When I kick off the .ps1 file via a command file; then emails send. But when I try to run it straight from the .pff (or .ps1 in PrimalScript) I get the above error. Has anyone seen this before?
Thanks in advanced,
Mike
Code being used:
$oSMTP = new-object Net.Mail.SmtpClient("smtp.company.com")
$sToAddress = "User_1@company.com"
$sCCAddress = "User_2@company.com"
$sSubject = "Here Is The Info You Requested"
$oMSG = new-object Net.Mail.MailMessage
$oMSG.From = "Team_A@company.com"
$oMSG.To.Add($sToAddress)
$oMSG.CC.Add($sCcAddress)
$oMSG.Subject = $sSubject
$oMSG.Body = "Information...`nThanks"
$oSMTP.Send($oMSG)
Sending Emails via PrimalForms
Sending Emails via PrimalForms
It's hard to tell since the error message does not provide much information. Have you to tried packaging the script into an executable? It may have to do with user permissions. Does the smtp server require login credentials?
You may want to try www.ScriptingAnswers.com for further help.
David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Sending Emails via PrimalForms
Hi David. Yes, when I package in in the .exe it still does not send the email. As for permissions, I don't believe that is an issue. I have scripted sending emails before (using PrimalScript launched by a .cmd file) and those work. It just when running within PrimalForms/PrimalScript (not kicking the script off via a .cmd file).
Thanks,
Mike
Thanks,
Mike
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Sending Emails via PrimalForms
Could be type problem. Try to declare the message
specifically as [System.Net.Mail.MailMessage]
because the Send method has an overload
Send(string from,string recipients,string subject,string body)
specifically as [System.Net.Mail.MailMessage]
because the Send method has an overload
Send(string from,string recipients,string subject,string body)
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Sending Emails via PrimalForms
Did some research, seems the most common cause for that problem is that a firewall is blocking port 25. Exceptions are usually configured for mail clients and maybe you have an exception for powershell.exe.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Sending Emails via PrimalForms
I also ran a test on our end and I was able to send emails using the StmpClient within PrimalForms.
David
David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Sending Emails via PrimalForms
I checked and it is because it's blocked at port 25. When the form gets packaged, what is called to run the script when the .exe is launched?
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Sending Emails via PrimalForms
It doesn't call anything. The exe is the one that is executing the powershell script.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Sending Emails via PrimalForms
Are there any special securities added within PrimalForms? Our environment isn't denying the email from being sent; it's being denied somewhere within PrimalForms or within PowerShell itself.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Sending Emails via PrimalForms
I am sure there is nothing within the custom host PrimalForms uses. Switch on logging in whatever firewall you are using. Do you need authentication when sending email?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.