Sending Emails via PrimalForms

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
This topic is 14 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
drukamp
Posts: 42
Last visit: Fri May 12, 2023 8:36 am
Has voted: 1 time

Sending Emails via PrimalForms

Post by drukamp »

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)
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Sending Emails via PrimalForms

Post by davidc »


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.
User avatar
drukamp
Posts: 42
Last visit: Fri May 12, 2023 8:36 am
Has voted: 1 time

Sending Emails via PrimalForms

Post by drukamp »

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
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Sending Emails via PrimalForms

Post by Alexander Riedel »

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)
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Sending Emails via PrimalForms

Post by Alexander Riedel »

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.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Sending Emails via PrimalForms

Post by davidc »

I also ran a test on our end and I was able to send emails using the StmpClient within PrimalForms.







David
David
SAPIEN Technologies, Inc.
User avatar
drukamp
Posts: 42
Last visit: Fri May 12, 2023 8:36 am
Has voted: 1 time

Sending Emails via PrimalForms

Post by drukamp »

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?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Sending Emails via PrimalForms

Post by Alexander Riedel »

It doesn't call anything. The exe is the one that is executing the powershell script.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
drukamp
Posts: 42
Last visit: Fri May 12, 2023 8:36 am
Has voted: 1 time

Sending Emails via PrimalForms

Post by drukamp »

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.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Sending Emails via PrimalForms

Post by Alexander Riedel »

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.
This topic is 14 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.