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

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????
anupam1983Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

exx1976Commented:
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
RudramCommented:
* 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
anupam1983Author Commented:
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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

exx1976Commented:
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
exx1976Commented:
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
anupam1983Author Commented:
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
exx1976Commented:
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
exx1976Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anupam1983Author Commented:
Thanks a lot. You are just amazing! I am very greatful to you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.