Page 1 of 1

Email field error

Posted: Wed Mar 04, 2015 8:56 am
by smurphy0822
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

Posted: Wed Mar 04, 2015 8:56 am
by SAPIEN Support Forums
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: If you asked in the wrong forum, just copy your question to the right forum.

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
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***

Re: Email field error

Posted: Wed Mar 04, 2015 9:18 am
by jvierra
We can't guess without seeing the code you are using to create the string.

Re: Email field error

Posted: Wed Mar 04, 2015 10:59 am
by smurphy0822
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
}

Re: Email field error

Posted: Wed Mar 04, 2015 11:09 am
by jvierra
You fail to show how you are calling this function. The function has no textboxes in it.

Re: Email field error

Posted: Wed Mar 04, 2015 12:57 pm
by jvierra
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."
}