none
Powershell Script to Automate sending a text message -- Google Voice

    Question

  • Need to complete this script to text my phone and let me know my computer is connected to the VPN. Anyone able to see any coding problems?

    #Variables $username_or_email = "USERNAME"; $password = "PASSWORD"; $url = "https://accounts.google.com/ServiceLogin?service=grandcentral&passive=1209600&continue=https://www.google.com/voice&followup=https://www.google.com/voice&ltmpl=open"; $phone = "YOURNUMBER" $send = $sending | where {$_.innerText -eq 'Send'} $text = $texts | where {$_.innerText -eq 'Text'} $ProcessActive = Get-Process dsNetworkConnect -ErrorAction SilentlyContinue if($ProcessActive -eq $null) { # Create an ie com object $ie = New-Object -com internetexplorer.application; $ie.visible = $true; $ie.navigate($url); # Wait for the page to load while ($ie.Busy -eq $true) { Start-Sleep -Milliseconds 3000; } # Add login details $ie.Document.getElementById("Email").value = $username_or_email; $ie.Document.getElementById("Passwd").value = $password; while ($ie.Busy -eq $true) { Start-Sleep -Milliseconds 5000; } # Click the button to login. $ie.Document.getElementById("signIn").Click(); # Wait for the page to load while ($ie.Busy -eq $true) { Start-Sleep -Milliseconds 5000; } # Hidden click text button -- no visual that it clicked it if you watching this run $ie.Document.getElementById("$text").Click(); # Insert phone number, message, and send it. $ie.Document.getElementById("gc-quicksms-number").value = "$phone" $ie.Document.getElementById('gc-quicksms-text2').SetAttribute('value','Connected') $ie.Document.getElementById("$send").Click(); } else { # Create an ie com object $ie = New-Object -com internetexplorer.application; $ie.visible = $true; $ie.navigate($url); # Wait for the page to load while ($ie.Busy -eq $true) { Start-Sleep -Milliseconds 3000; } # Add login details $ie.Document.getElementById("Email").value = $username_or_email; $ie.Document.getElementById("Passwd").value = $password; while ($ie.Busy -eq $true) { Start-Sleep -Milliseconds 5000; } # Click the button to login. $ie.Document.getElementById("signIn").Click(); # Wait for the page to load while ($ie.Busy -eq $true) { Start-Sleep -Milliseconds 5000; } # Hidden click text button -- no visual that it clicked it if you watching this run $ie.Document.getElementById("$text").Click(); # Insert phone number, message, and send it. $ie.Document.getElementById("gc-quicksms-number").value = "$phone" $ie.Document.getElementById('gc-quicksms-text2').SetAttribute('value','Not Connected') $ie.Document.getElementById("$send").Click(); }



    • Edited by daemongpl Thursday, March 28, 2013 9:36 PM
    Thursday, March 28, 2013 9:32 PM

Answers

  • Last I checked, gmail still provided SMTP relay service to support POP3 clients.  This means you should just be able to use send-mailmessage with mail.gmail.com as the SMTPServer, and using your gmail username and password for the credentials.  Your phone provider should have an SMS email gateway you can address the email to and the body of the email will get sent to your phone as a text message.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "


    Thursday, March 28, 2013 9:45 PM
    Moderator

All replies

  • Last I checked, gmail still provided SMTP relay service to support POP3 clients.  This means you should just be able to use send-mailmessage with mail.gmail.com as the SMTPServer, and using your gmail username and password for the credentials.  Your phone provider should have an SMS email gateway you can address the email to and the body of the email will get sent to your phone as a text message.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "


    Thursday, March 28, 2013 9:45 PM
    Moderator
  • THANK YOU!!!!


    #Alltel
    #1234567890@message.alltel.com

    #AT&T
    #1234567890@txt.att.net

    #Boost Mobile
    #1234567890@myboostmobile.com

    #MetroPCS
    #1234567890@mymetropcs.com

    #Nextel
    #1234567890@messaging.nextel.com

    #Sprint PCS
    #1234567890@messaging.sprintpcs.com

    #T-Mobile
    #1234567890@tmomail.net

    #Verizon
    #1234567890@vtext.com

    #Virgin Mobile
    #1234567890@vmobl.com

    #Variables
    $email = "USERNAME@GMAIL.COM"
    $phone = "YOURNUMBER@ABOVE.COM

    $ProcessActive = Get-Process dsNetworkConnect -ErrorAction SilentlyContinue
    if($ProcessActive -eq $null)
    {

    $EmailFrom = $email
    $EmailTo = $phone
    $Subject = "Message from your computer"
    $Body = "VPN is connected."
    $SMTPServer = "smtp.gmail.com"
    $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
    $SMTPClient.EnableSsl = $true
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("USERNAME", "PASSWORD");
    $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
    }
    else
    {
    $EmailFrom = $email
    $EmailTo = $phone
    $Subject = "Notification Computer"
    $Body = "VPN did not connect!!!!!"
    $SMTPServer = "smtp.gmail.com"
    $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
    $SMTPClient.EnableSsl = $true
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("USERNAME", "PASSWORD");
    $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
    }

    Thursday, March 28, 2013 10:17 PM
  • If you have two-factor authentication setup on your gmail account you can you use an application specific password.

    Send-MailMessage -Body "You're able to send SMS messages through email." `
    -From 'emailaddress@gmail.com' `
    -To '1234567890@vtext.com' `
    -SmtpServer 'smtp.gmail.com' `
    -Credential (Get-Credential) ` #Enter in your application specific password.
    -Subject 'Test' `
    -Port 587 `
    -UseSsl


    Tuesday, June 11, 2013 9:01 PM
  • I am getting an error when running this script. It is unable to find the text click

    $ie.Document.getElementById("$text").Click();

    Do you have any work arounds or you know how to make this run ?

    Feedback appreciated!

    Thanks,

    Priyesh

    Wednesday, August 13, 2014 5:56 PM
  • I am getting an error when running this script. It is unable to find the text click

    $ie.Document.getElementById("$text").Click();

    Do you have any work arounds or you know how to make this run ?

    Feedback appreciated!

    Thanks,

    Priyesh

    Can't be done.  Please read the whole thread carefully and note that the answer does not use this method.


    ¯\_(ツ)_/¯

    Wednesday, August 13, 2014 9:53 PM