I have created a GUI with a textbox where our help desk will be able to included a help desk ticket number, which will then update the ticket.
For this to work correctly, the text needs to be sent in the below format
RE: [Ticket #XXXXX]
I have attempted several time to get this to work with no luck.
What shows up in the email, where RE: [Ticket #XXXXX] should be is the textbox property name. See below.
RE: Ticket:System.Windows.form.text
How do I format so it will send field correctly?
Email field error
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- SAPIEN Support Forums
- Posts: 945
- Last visit: Thu Oct 22, 2015 1:10 pm
Email field error
This is an automated post. A real person will respond soon.
Thank you for posting, smurphy0822.
Here are some hints to help you get an accurate and complete answer to your question.
Ask in the best forum:
Anticipate follow-up questions!
Did you remember to include the following?
*** Make sure you do not post any licensing information ***
Thank you for posting, smurphy0822.
Here are some hints to help you get an accurate and complete answer to your question.
Ask in the best forum:
- - Scripting question? For questions about Windows PowerShell or other scripting languages, use Scripting Answers.
- Software question? For questions about PowerShell Studio, PrimalScript, or other SAPIEN products, use Product Support Forums for Registered Customers.
- Trial question? For questions about trial versions of any SAPIEN product, use Trial Software Questions.
Anticipate follow-up questions!
Did you remember to include the following?
- 1. Product, version and build
2. 32 or 64 bit product
3. Operating system, e.g. Windows 7 64 bit.
4. Attach a screenshot, if applicable
5. Attach logs, crash reports, etc., in a ZIP file
*** Make sure you do not post any licensing information ***
- smurphy0822
- Posts: 6
- Last visit: Wed May 11, 2022 9:49 am
Re: Email field error
Here is the code
Function SendUnlockEmail([string]$x, [string]$y, [int]$z=0, [string]$smtpServer) {
if ($z -gt 0) #you did input a ticket #. Send email to SpiceWorks helpdesk
{
$to = "helpdesk@YourCompany"
$subject = "RE: [Ticket #$z]"
}
$from = $y
$body = $user.cn + ",
Users account has been Off-Boarded per HR's request.
"Closed by + $env:USERNAME + "
#assign to $y
#add 10m
#due in 1 business day
#category User Account"
Send-MailMessage -To $to -From $from -Cc $from -Subject $subject -Body $body -SmtpServer $smtpServer
Write-Host
The user" $user.Name "has successfully been unlocked and an email has been sent to $to.
# end function SendUnlockEmail
}
Function SendUnlockEmail([string]$x, [string]$y, [int]$z=0, [string]$smtpServer) {
if ($z -gt 0) #you did input a ticket #. Send email to SpiceWorks helpdesk
{
$to = "helpdesk@YourCompany"
$subject = "RE: [Ticket #$z]"
}
$from = $y
$body = $user.cn + ",
Users account has been Off-Boarded per HR's request.
"Closed by + $env:USERNAME + "
#assign to $y
#add 10m
#due in 1 business day
#category User Account"
Send-MailMessage -To $to -From $from -Cc $from -Subject $subject -Body $body -SmtpServer $smtpServer
Write-Host
The user" $user.Name "has successfully been unlocked and an email has been sent to $to.
# end function SendUnlockEmail
}
Re: Email field error
This will get you closer to something that works:
PowerShell Code
Double-click the code block to select all.#template $body=@' {0} Users account has been Off-Boarded per HR's request. Closed by {1} #assign to {2} #add 10m #due in 1 business day #category User Account '@ if($TextBox.Text -notmatch '\d{5}'){ #you did input a ticket }else{ #Send email to SpiceWorks helpdesk $mailprops=@{ To='helpdesk@YourCompany' From=$y Cc=$from Subject=('RE: [Ticket #{0}' -f $Textbox1.Text) Body=($template -f $user.cn,$y,$z) SmtpServer=$smtpServer } Send-MailMessage @mailprops Write-Host 'The user $($user.Name) has successfully been unlocked and an email has been sent to $to." }