Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Tanuki
Novice


Joined: 06 Nov 2008
Posts: 38

PostPosted: Mon Aug 17, 2015 5:59 am   

Email from CMUD
 
I needed an email notification from CMUD today and couldn't find an easy way.
This is what I came up with using PowerShell 4.0 and VBScript. Hope someone else can use it.

1. Download Powershell V4 if you don't already have it.

2. Create the file c:\temp\email-notification.ps1 with the contents of

[object] $objCred = $null
[string] $strUser = 'UserNameForEmailAccount'
$strPass = ConvertTo-SecureString -String "PasswordForEmailAccount" -AsPlainText -Force
$objCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($strUser, $strPass)

Send-MailMessage -SmtpServer "smtp-relay.google.com" -From "cmud@client.net" -To "phonenumber@vtext.com" -Subject "Notification Message" -Body "Body Message" -Credential $objCred


3. Create Button, Trigger, whatever and change the Language from ZScript to VBScript

Set objShell = CreateObject("Wscript.Shell")
objShell.Run("powershell.exe c:\temp\email-notification.ps1")
Reply with quote
Farek
Beginner


Joined: 13 Oct 2004
Posts: 29

PostPosted: Tue Aug 18, 2015 3:58 pm   
 
thx for this one :)
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Sun Dec 25, 2016 10:17 pm   
 
I created an alias. How do I correctly submit parameters to powershell?

if it was zscript ...
Code:
objShell.Run(%concat("powershell.exe c:\temp\email-notification.ps1", %-1))
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Dec 26, 2016 8:49 pm   
 
For your alias use the following zScript:
$obj=%comcreate("WScript.shell")
#CALL {$obj.Run(%concat("powershell.exe filepath ", %-1))}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Tue Jan 10, 2017 8:53 pm   
 
I have one problem with email-notification


Code:
[object] $objCred = $null
[string] $strUser = 'kyksinski'
$strPass = ConvertTo-SecureString -String "secretpassword" -AsPlainText -Force
$objCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($strUser, $strPass)

Send-MailMessage -SmtpServer "smtp.wp.pl" -From "secret.email@wp.pl" -To "secret.email@gmail.com" -Subject "Powiadomienie CMUD" -Body "$Args" -Credential $objCred


I have a universal alias to report things
Code:
<alias name="raportuj" id="1083">
  <value>#THREAD sounds
#say %-1
#WIN logs ERROR: %-1
email %-1
#IF (@sound=="yes") {#2 {#IF (@sound=="yes") {#play alert.wav;#wait 17000}}}
;#10 {#beep;#wait 100}</value>
</alias>

and
Code:
<alias name="email" id="1606">
  <value>$obj=%comcreate("WScript.shell")
#CALL {$obj.Run(%concat("powershell.exe c:\temp\email-notification.ps1 ", %-1))}</value>
</alias>



when i want to send
Code:
raportuj %concat("qm - no exits - required recall, room:", %roomvnum)
I receive e mail
Code:
qm - no exits - required System.Object[]


how can I solve this?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jan 11, 2017 11:15 pm   
 
I don't know why you have the line #THREAD sounds there. If you want to create a separate thread you have to put the script portion in the command such as:
#THREAD sounds {do stuff}

What you probably would want to do is combine a few lines like this:
#IF (@sound=="yes) {#THREAD sounds {#2 {#PLAY alert.wav;#WAIT 17000}}}

Now to your actual problem. What do all the #SAY and #WIN lines display for %-1? If you always use the same message then you might program it directly into the alias. If you don't use the email alias separately then you might be better off putting those 2 lines into the raportuj alias.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Thu Jan 12, 2017 12:55 pm   
 
The error occurs only when the string contains a comma or |
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Jan 13, 2017 6:01 pm   
 
Try this:
#CALL {$obj.Run(%concat("powershell.exe c:\temp\email-notification.ps1 """, %-1, """"))}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Sat Jan 14, 2017 10:38 am   
 
Nope. ;)

but I was looking for a few days in the documentation and wrote something like this:

Code:
#CALL {$obj.Run(%concat("powershell.exe c:\temp\email-notification.ps1 ", %replace(%replace(%-1,",","`,"),"|","`|")))}


@Vijilante Thank you very much for your advice and involvement
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net