Solved

send email on schedulle

Posted on 2014-02-04
15
847 Views
Last Modified: 2014-02-04
Experts Exchange > Other > Lounge > Send Email On Schedule
Question
View SolutionAsk A New Question
send email on schedule
Asked by: ger2111
Solved by: captain
Hi,
I want to send notification emails on a fortnightly basis in a specific time window to a select number of users. I do not want to use outlook for this purpose , is there a way I can do this within exchange 2010 or can I use DB Mail in SQL 2005. Or is there some third party software that you can reccoment that will achieve same.

Thanks,
Ger
0
Comment
Question by:ger2111
  • 9
  • 6
15 Comments
 
LVL 19

Expert Comment

by:n2fc
ID: 39831905
See the following article for a sample PowerShell script to send emails...

http://www.howtogeek.com/120011/stupid-geek-tricks-how-to-send-email-from-the-command-line-in-windows-without-extra-software/

Just create the appropriate script & use the task scheduler to run it every couple'a weeks...
0
 

Author Comment

by:ger2111
ID: 39832095
working with this, seeing

The remote certificate is invalid according to the validation procedure when I try to run the script,

think its to do with out exchange certificates, is there a way around this?
thanks,
Ger
0
 
LVL 19

Expert Comment

by:n2fc
ID: 39832104
You will need to manually add the certificate as valid to the machine running the script as it is probably self-signed and not from a recognized certification authority.
0
 

Author Comment

by:ger2111
ID: 39832107
running the script on the exchange server -

How do I validate certificates - -

TYTYTY
0
 
LVL 19

Expert Comment

by:n2fc
ID: 39832117
When  you get the certificate error, check to see the cause...
It will either be due to expired (so renew it) or due to unrecognized certification authority (so you must manually add to trusted cert db)
0
 

Author Comment

by:ger2111
ID: 39832126
thanks for this -
the error in full:
Exception calling "Send" with "4" argument(s): "The remote certificate is invalid according to the validation procedur
."
At line:1 char:17
+ $SMTPClient.Send <<<< ($EmailFrom, $EmailTo, $Subject, $Body)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
0
 
LVL 19

Expert Comment

by:n2fc
ID: 39832142
Again, probably due to a self-signed certificate on the server...  (but check this)...

See:
http://blogs.msdn.com/b/jpsanders/archive/2009/09/16/troubleshooting-asp-net-the-remote-certificate-is-invalid-according-to-the-validation-procedure.aspx

for a procedure (step 1) to verify & correct this error...
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:ger2111
ID: 39832144
the first line of step one has me -
One super handy and technical tool to help you do this first step is Internet Explorer.  Simply try to hit the same URL that your ASP.NET web application tries to hit when it gets this error.  For example, type in to the browser the path to the .asmx file and see what Internet Explorer says about the certificate.

dont see any url in the error, using ie and browsing to https://exchangeserver returns the standard IIS splash screen.

stuck at this point..
0
 
LVL 19

Accepted Solution

by:
n2fc earned 500 total points
ID: 39832161
If you are using a local server (i.e. "exchangeserver") and it is setup to accept SMTP on port 25 as well, try NOT using SSL and port 25 to avoid the need for certificates altogether...

I think by following the example too literally (the gmail example shows using SSL only because gmail requires it) it is overly complicated for you...

See if you can get around this by using standard port 25 WITHOUT SSL!
0
 

Author Comment

by:ger2111
ID: 39832176
here is my script: have changed to port 25 but do not see where i can change to not use SSL:

Thanks again,

$EmailFrom = "payroll@domain.com"
$EmailTo = "user@domain.com"
$Subject = "PAYROLL AUTHORISATION"
$Body = "This is an auto reminder to please ensure Payroll File is AUTHORISED today.”
$SMTPServer = "exchangeserver"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“domain\payroll”, “**********”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
0
 

Author Comment

by:ger2111
ID: 39832177
ah, i see it now! my apologies
0
 

Author Comment

by:ger2111
ID: 39832181
wonderful, i have it working now, last couple of questions,

if i want to add multiple reciepients just seperate with a semi colon right?

and another quich one, how do i save the script, i mean, copy into notepad, what is the extension i need to add?


Thanks so much.
0
 
LVL 19

Expert Comment

by:n2fc
ID: 39832206
1) recipients separated by comma (not semicolon)

2) I believe the extension for powershell scripts is ".ps1"
0
 

Author Comment

by:ger2111
ID: 39832238
still not getting the emails out to multiple users, can you provide correct syntak for two users and I will follow your lead :

I have "user@domain.com","user2@domain.com" etc but it doesnt like that, some searching would suggest that I may need to dd a $recipients somethere in the script?


Nearly there
Thanks again,
0
 

Author Closing Comment

by:ger2111
ID: 39832297
cracked it, many thanks for your timely assistance throughout. Much appreciated,
Ger
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now