Szukaj na tym blogu

wtorek, 26 maja 2015

VB script to send email from exchange

Dim objNTInfo
Set objNTInfo = CreateObject("WinNTSystemInfo")
GetComputerName = objNTInfo.ComputerName

mTo = WScript.Arguments.Item(0)
mFrom = "SCCM-OSD@domainB.com"
mSubject = "Need to change domainA.com email address to domainB.com in distribution groups"

mbody = "check content of c:\temp\listalista.txt on exchange server then use C:\temp\replaceAPdistList.ps1 "

sendmail mTo, mSubject, mBody, mFrom


Function SendMail(strTo,strSubject,strBody,strFrom)
Dim m_EmailObj, m_EmailConfig
Set m_EmailObj = CreateObject("CDO.Message")
m_EmailObj.From = strFrom
m_EmailObj.To = strTo
m_EmailObj.Subject = strSubject
'm_EmailObj.TextBody = strBody


m_EmailObj.HTMLBody = strBody
Set m_EmailConfig = m_EmailObj.Configuration
m_EmailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ExchangeServerName"
m_EmailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
m_EmailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
m_EmailConfig.Fields.Update
m_EmailObj.Send
Set m_EmailObj = nothing
Set m_EmailConfig = nothing
End Function

Brak komentarzy:

Prześlij komentarz