?
Solved

How to send bulk emails to users (Prior Notification mail)?

Posted on 2008-11-13
9
Medium Priority
?
354 Views
Last Modified: 2012-05-05
Hi Experts,

I will have to dismount 3 stores in a storage groups. Now I'ld like to inform all the effected users of those stores by sending a common email in bulk.

Can anyone please help me out????
0
Comment
Question by:anupam1983
  • 5
  • 3
9 Comments
 
LVL 18

Expert Comment

by:exx1976
ID: 22957447
You can do this with VBS..   If no one gets you a solution by morning, I'll post something up when I get to the office.
0
 
LVL 10

Expert Comment

by:Rudram
ID: 22957901
* Or else you can use any one of the freeware tools available to send out bulk emails. But before choosing any one of them make sure it doesn't get blocked as a Spammer

Good Luck (^_^)
0
 

Author Comment

by:anupam1983
ID: 22957912
Probably company policy won't allow me to use free tool as you said it can be banned as a spam-generating software....
By the way, can you name one such software which is secure...
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
LVL 18

Expert Comment

by:exx1976
ID: 22960849
Ok..  Here it is.  It's not pretty, but it does the job.

You need to use either LDP or ADSIEDIT and get the EXACT string for the value of homeMDB from one user from each of the Information Stores you want to send mail to.  This script will then send email to each user in that IS.  If you want it based on SG, let me know and I'll post up the change.  You'll need to paste that string into line 1, run the script, then paste in the string for the next SG, run it again, etc.  Also, this script is set to query only a single domain, the domain that the logged on user is a member of (meaning the account you use to run the script).  If you need that changed, let me know and I can make it for different/multiple domains.

You'll also need to edit line 2 and substitute the FQDN for your exchange server.

The last thing you'll need to edit are a couple lines in the MAIL sub.  From, Subject, Body..  That way the email says what you want it to say.

The script will output a text file with a list of names of people it emailed.   Enjoy!!

One last thing - you must run this script on a machine that has CDO installed (most common way is by installing Exchange Admin Tools).

HTH,
exx
InformationStoreDN = "CN=Store,CN=Group,CN=InformationStore,CN=Server,etc etc etc"
ExchangeServerFQDN = "myserver.mydomain.com"
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext") 
strOutput = "c:\report.txt"
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oOutput = oFS.OpenTextFile(strOutput, ForWriting, True)
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand =   CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "Active Directory Provider"
Set oCommand.ActiveConnection = objConnection
oCommand.Properties("Page Size") = 1000
oCommand.Properties("Searchscope") = 2
oCommand.CommandText = _
    "SELECT AdsPath FROM '" & strADsPath & "' WHERE homeMDB='" & InformationStoreDN & "'"
Set oRecordSet = oCommand.Execute
oRecordSet.MoveFirst
Do Until oRecordSet.EOF
    Set oUser = GetObject(oRecordSet.Fields("AdsPath").Value)
	Mail oUser.emailaddress
	oOutput.WriteLine(oUser.DisplayName)
    oRecordSet.MoveNext
Loop
oOutput.Close
 
Sub Mail(MailTo)
	Set oEmail = CreateObject("CDO.Message")
	oEmail.From = "Administrator@mycompany.com"
	oEmail.To = MailTo
	oEmail.Subject = "Mail Server Maintenance"
	oEmail.Textbody = "The mail server will be going down for maintenance between the hours of blah blah and blah blah"
	oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ExchangeServerFQDN
	oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	oEmail.Configuration.Fields.Update
	oEmail.Send
End Sub

Open in new window

0
 
LVL 18

Expert Comment

by:exx1976
ID: 22960877
My apologies, I just noticed something..

Use this version instead (had to change line 8)


-exx
InformationStoreDN = "CN=Store,CN=Group,CN=InformationStore,CN=Server,etc etc etc"
ExchangeServerFQDN = "myserver.mydomain.com"
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext") 
strOutput = "c:\report.txt"
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oOutput = oFS.OpenTextFile(strOutput, 2, True)
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand =   CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "Active Directory Provider"
Set oCommand.ActiveConnection = objConnection
oCommand.Properties("Page Size") = 1000
oCommand.Properties("Searchscope") = 2
oCommand.CommandText = _
    "SELECT AdsPath FROM '" & strADsPath & "' WHERE homeMDB='" & InformationStoreDN & "'"
Set oRecordSet = oCommand.Execute
oRecordSet.MoveFirst
Do Until oRecordSet.EOF
    Set oUser = GetObject(oRecordSet.Fields("AdsPath").Value)
	Mail oUser.emailaddress
	oOutput.WriteLine(oUser.DisplayName)
    oRecordSet.MoveNext
Loop
oOutput.Close
 
Sub Mail(MailTo)
	Set oEmail = CreateObject("CDO.Message")
	oEmail.From = "Administrator@mycompany.com"
	oEmail.To = MailTo
	oEmail.Subject = "Mail Server Maintenance"
	oEmail.Textbody = "The mail server will be going down for maintenance between the hours of blah blah and blah blah"
	oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ExchangeServerFQDN
	oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	oEmail.Configuration.Fields.Update
	oEmail.Send
End Sub

Open in new window

0
 

Author Comment

by:anupam1983
ID: 22962098
Hi Exx1976,

Thanks a ton for this script! You mentioned to change line 8, what exactly I need to change up there? And since all the stores are in the same storage group, so it'ld be better if you can provide me this script for SG, otherwise it's cool! :)

Another help, how to learn this kind of VBS scripting for Exchange Server? Can you suggest some link or books?

Many Thanks!
Anupam
0
 
LVL 18

Expert Comment

by:exx1976
ID: 22962730
No, no..  I had to make a change to line 8.  In the first version in line 8 I had an undeclared constant in there, so I just changed it to the value.  The only things you need to change are lines 1 and 2, and then the stuff in the mail sub - from, subject, textbody..


Oh boy..  To learn?  Well, it's not really any harder to script Exchange than it is any other part of AD..  It's all just properties of a user object, or a group object, or a computer object, or..  Well, you get the idea.  Getting the property names are the easiest part, you can just look them up with ADSIEdit or LDP.

If I had to recommend a way to learn..  If you have NO programming background at all, then I'd try and take M$ class 2433.  It's a 3-day class that teaches scripting essentials.  Then I'd pick up the book "Windows 2000 scripting bible", ISBN 0-7645-4677-5

Another good place is the TechNet scripting center.  http://www.microsoft.com/technet/scriptcenter/default.mspx  Be careful though, I've found several mistakes in there..  But such is the risk you run with direct-to-web published content.  There is rarely a proofreader or technical reviewer, it's posted more blog-style, so mistakes are easier to get in.

Either way, glad I could help.

The script below should spam all mailboxes in all IS's in a SG.  You'll need to enter the name of the SG on line 1, the FQDN of your Exchange server on line 2, and you'll need to edit the mail sub again.

Enjoy!!

StorageGroup = "MyStorageGroup"
ExchangeServerFQDN = "myserver.mydomain.com"
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext") 
strOutput = "c:\report.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oOutput = oFSO.OpenTextFile(strOutput, 2, True)
ExchSrvr = Split(ExchangeServerFQDN,".")
SGReport ExchSrvr(0)
objOutput.Close
 
Sub SGReport(strServer)
	Set iServer=CreateObject("CDOEXM.ExchangeServer")
	Set iSGs=CreateObject("CDOEXM.StorageGroup")
	iServer.DataSource.Open strServer
	arrSGs=iServer.StorageGroups
	For i=0 To UBound(arrSGs)
	    strSGUrl=arrSGs(i)
	    iSGs.DataSource.Open "LDAP://" & iServer.DirectoryServer & "/" & strSGUrl
	    If LCase(iSGs.Name) = LCase(StorageGroup) Then
		    For Each object In iSGs.MailboxStoreDBs
		    	Spam object
		    Next
		End If
	Next
End Sub
 
Sub Spam(InformationStoreDN)
	Set oConnection = CreateObject("ADODB.Connection")
	Set oCommand =   CreateObject("ADODB.Command")
	oConnection.Provider = "ADsDSOObject"
	oConnection.Open "Active Directory Provider"
	Set oCommand.ActiveConnection = oConnection
	oCommand.Properties("Page Size") = 1000
	oCommand.Properties("Searchscope") = 2
	oCommand.CommandText = "SELECT * FROM '" & strADsPath & "' WHERE homeMDB='" & InformationStoreDN & "'"
	Set oRecordSet = oCommand.Execute
	oRecordSet.MoveFirst
	Do Until oRecordSet.EOF
	    Set oUser = GetObject(oRecordSet.Fields("AdsPath").Value)
		Mail objUser.emailaddress
		oOutput.WriteLine(objUser.DisplayName)
	    oRecordSet.MoveNext
	Loop
End Sub
 
Sub Mail(MailTo)
	Set objEmail = CreateObject("CDO.Message")
	objEmail.From = "Administrator@mycompany.com"
	objEmail.To = MailTo
	objEmail.Subject = "Mail Server Maintenance"
	objEmail.Textbody = "The mail server will be going down for maintenance between the hours of blah blah and blah blah"
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ExchangeServerFQDN
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	objEmail.Configuration.Fields.Update
	objEmail.Send
End Sub

Open in new window

0
 
LVL 18

Accepted Solution

by:
exx1976 earned 2000 total points
ID: 22962760
D'oh!  I see another typo..  Use this one instead, sorry about that.


StorageGroup = "MyStorageGroup"
ExchangeServerFQDN = "myserver.mydomain.com"
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext") 
strOutput = "c:\report.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oOutput = oFSO.OpenTextFile(strOutput, 2, True)
ExchSrvr = Split(ExchangeServerFQDN,".")
SGReport ExchSrvr(0)
oOutput.Close
 
Sub SGReport(strServer)
	Set iServer=CreateObject("CDOEXM.ExchangeServer")
	Set iSGs=CreateObject("CDOEXM.StorageGroup")
	iServer.DataSource.Open strServer
	arrSGs=iServer.StorageGroups
	For i=0 To UBound(arrSGs)
	    strSGUrl=arrSGs(i)
	    iSGs.DataSource.Open "LDAP://" & iServer.DirectoryServer & "/" & strSGUrl
	    If LCase(iSGs.Name) = LCase(StorageGroup) Then
		    For Each object In iSGs.MailboxStoreDBs
		    	Spam object
		    Next
		End If
	Next
End Sub
 
Sub Spam(InformationStoreDN)
	Set oConnection = CreateObject("ADODB.Connection")
	Set oCommand =   CreateObject("ADODB.Command")
	oConnection.Provider = "ADsDSOObject"
	oConnection.Open "Active Directory Provider"
	Set oCommand.ActiveConnection = oConnection
	oCommand.Properties("Page Size") = 1000
	oCommand.Properties("Searchscope") = 2
	oCommand.CommandText = "SELECT * FROM '" & strADsPath & "' WHERE homeMDB='" & InformationStoreDN & "'"
	Set oRecordSet = oCommand.Execute
	oRecordSet.MoveFirst
	Do Until oRecordSet.EOF
	    Set oUser = GetObject(oRecordSet.Fields("AdsPath").Value)
		Mail objUser.emailaddress
		oOutput.WriteLine(objUser.DisplayName)
	    oRecordSet.MoveNext
	Loop
End Sub
 
Sub Mail(MailTo)
	Set objEmail = CreateObject("CDO.Message")
	objEmail.From = "Administrator@mycompany.com"
	objEmail.To = MailTo
	objEmail.Subject = "Mail Server Maintenance"
	objEmail.Textbody = "The mail server will be going down for maintenance between the hours of blah blah and blah blah"
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ExchangeServerFQDN
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	objEmail.Configuration.Fields.Update
	objEmail.Send
End Sub

Open in new window

0
 

Author Closing Comment

by:anupam1983
ID: 31516668
Thanks a lot. You are just amazing! I am very greatful to you!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

830 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