Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
General PowerShell
Email Credentials
Last Post 01 Mar 2010 08:10 AM by
Shay Levy
. 1 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
Rob Burgess
New Member
Posts:1
21 Feb 2010 11:47 AM
Hi
I found the attached code from Shay Levy to send and email via GMail. I was wondering how you enter the GMail credentials in the code so you are not prompted for credentials.
Thanks
email.txt
Shay Levy
PowerShell MVP, Admin
Veteran Member
Posts:1362
01 Mar 2010 08:10 AM
$GmailID = "foo"
$GmailPass="bar"
$SmtpClient = new-object system.net.mail.smtpClient
$smtpclient.Host = 'smtp.gmail.com'
$smtpclient.Port = 587
$smtpclient.EnableSsl = $true
$smtpClient.Credentials = New-Object System.Net.NetworkCredential $GmailID ,$GmailPass
$smtpclient.Send("$GmailID@gmail.com","someone@domain.com", "test subject","test message")
Shay Levy
Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter:
@ShayLevy
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
General PowerShell
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2