rolamohammed
asked on
Create Specifc Distribution List under Specific Folder .
Dear All,
refrence to my request on this URL :-
https://www.experts-exchange.com/questions/21844678/About-Repeating-the-Script-For-Mr-Brian.html
Q2:- is there anyway to write a script ( I will consider it Script E ), to create Specific Distribution List ( called - Finance ), in Specific Folder ( SEMSEM ) which has been created by using Script A or B, and it takes all the information or its Members from the same file which is located on ("\\Ho-it-htaguiam\test2\e
--------------------------
ASKER
i will test it now, and i will reply to you .
ok thanks, i'l be away for a few hours but will check back in later
ASKER
OK
ASKER
Yes, Brian .
its working but there is some error .
first it create folder called finance .
But what i want is :-
1- it will create a group ( New Distribution List ) , under the Folder which has been created before by using Script A, and then it will take all the Users who are in the same folder which is :-
("\\Ho-it-htaguiam\test2\e
but it will take all the Information, from Sheet 2 , instead of Sheet 1
Please Help me to do that .
what i see from the script is , Create Folder NAME FINANCE , and there is no any Distrbution list has been created and
no users has been added to the Group it self.
please urgent help me .
ASKER
brian
is there any news about it , please help me and do not leave me , i trust you man .
is there any news about it , please help me and do not leave me , i trust you man .
ASKER
please , brian help me .
i'm back here now, its saturday here much like your friday :)
ok i misunderstood and created a folder with the contacts but you want a distribution list with the contacts from sheet 2
be right back
ok i misunderstood and created a folder with the contacts but you want a distribution list with the contacts from sheet 2
be right back
how does sheet 2 look like? can you give a sample of a row? adding members to a distribution list is easy [mail entry only] or difficult [contact entry]
ASKER
Thanks , for your always Help , i am so soory , that i forget your Weekend .
Take your Time , its friday for you .
anyway, take it easy , i need it to be on the same file and the same sheet, please discard what i said .
make it normal.
its here CAIRO , 9:06 AM here . Morning 14-MAY-2006
Take your Time , its friday for you .
anyway, take it easy , i need it to be on the same file and the same sheet, please discard what i said .
make it normal.
its here CAIRO , 9:06 AM here . Morning 14-MAY-2006
ASKER
Ya Brian ,
What i need is :-
1- No need to create any Folder, we will assume that the Folder " SEMSEM " Has been Created in the Script A.
2- IT will make only one Group " Distribution List " Called " FInance Group ".
3- Take only the Name & E-mails from Excel sheet , ( sheet 1 ) , and it will Put the User Name & E-mail Address.
Thanks For your Help man.
What i need is :-
1- No need to create any Folder, we will assume that the Folder " SEMSEM " Has been Created in the Script A.
2- IT will make only one Group " Distribution List " Called " FInance Group ".
3- Take only the Name & E-mails from Excel sheet , ( sheet 1 ) , and it will Put the User Name & E-mail Address.
Thanks For your Help man.
ASKER
Yes brian ,
please once you have time , try to find this for me , please brian.
Hi Rola,
This is script E creating a distribution list "Finance" based on the info from the excel sheet, just see if it works and if you need some other parts added to it like sending a confirmation mail
'------------------
' SCRIPT E
'------------------
'this script will
'1. add a new distribution list called Finance
'2. use the mail addressses from the SEMSEM contacts
'------------------
Dim objNS, oOlFolder As MAPIFolder, objOutlook, objExcel, objWorkbook, x, objContact
Dim myItems, strFirstName, strLastName, strFileAs
Dim myDistList, myRecipients, myTempItem, strfullName, strEmail1Address
Const olFolderContacts = 10
Const olDistributionListItem = 69
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objNS = objOutlook.GetNamespace("M API")
Set myDistList = objOutlook.CreateItem(olDi stribution ListItem)
myDistList.DLName = "Finance"
Set myTempItem = objOutlook.CreateItem(olMa ilItem)
Set myRecipients = myTempItem.Recipients
Set objExcel = CreateObject("Excel.Applic ation")
Set objWorkbook = objExcel.Workbooks.Open("\ \Ho-it-hta guiam\test 2\egypt-2. xls")
x = 1
Do Until objWorkbook.Sheets(1).Cell s(x, 1).Value = ""
strfullName = objWorkbook.Sheets(1).Cell s(x, 1).Value
strEmail1Address = objWorkbook.Sheets(1).Cell s(x, 3).Value
myRecipients.Add strfullName & "<" & strEmail1Address & ">"
x = x + 1
Loop
myDistList.AddMembers myRecipients
myDistList.Save
Set myTempItem = Nothing
Set myRecipients = Nothing
Set myDistList = Nothing
Set myItems = Nothing
Set oOlFolder = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
objWorkbook.Close False
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
'------------------
This is script E creating a distribution list "Finance" based on the info from the excel sheet, just see if it works and if you need some other parts added to it like sending a confirmation mail
'------------------
' SCRIPT E
'------------------
'this script will
'1. add a new distribution list called Finance
'2. use the mail addressses from the SEMSEM contacts
'------------------
Dim objNS, oOlFolder As MAPIFolder, objOutlook, objExcel, objWorkbook, x, objContact
Dim myItems, strFirstName, strLastName, strFileAs
Dim myDistList, myRecipients, myTempItem, strfullName, strEmail1Address
Const olFolderContacts = 10
Const olDistributionListItem = 69
Set objOutlook = CreateObject("Outlook.Appl
Set objNS = objOutlook.GetNamespace("M
Set myDistList = objOutlook.CreateItem(olDi
myDistList.DLName = "Finance"
Set myTempItem = objOutlook.CreateItem(olMa
Set myRecipients = myTempItem.Recipients
Set objExcel = CreateObject("Excel.Applic
Set objWorkbook = objExcel.Workbooks.Open("\
x = 1
Do Until objWorkbook.Sheets(1).Cell
strfullName = objWorkbook.Sheets(1).Cell
strEmail1Address = objWorkbook.Sheets(1).Cell
myRecipients.Add strfullName & "<" & strEmail1Address & ">"
x = x + 1
Loop
myDistList.AddMembers myRecipients
myDistList.Save
Set myTempItem = Nothing
Set myRecipients = Nothing
Set myDistList = Nothing
Set myItems = Nothing
Set oOlFolder = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
objWorkbook.Close False
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
'------------------
ASKER
Yes Brian , good morning.
i need please the confirmation Part of the E-mail .
i return back to the work, its toooo cloudy here in Egypt. Local Time in Jeddah is 9:05 AM Morning
its 08.13 AM here in Amstedam, sunny and cool
this is the script containing a confirmation email
'------------------
' SCRIPT E
'------------------
'this script will
'1. add a new distribution list called Finance
'2. use the mail addressses from the SEMSEM contacts
'------------------
Dim objNS, oOlFolder As MAPIFolder, objOutlook, objExcel, objWorkbook, x, objContact
Dim myItems, strFirstName, strLastName, strFileAs
Dim myDistList, myRecipients, myTempItem, strfullName, strEmail1Address
Const olFolderContacts = 10
Const olDistributionListItem = 69
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objNS = objOutlook.GetNamespace("M API")
Set myDistList = objOutlook.CreateItem(olDi stribution ListItem)
myDistList.DLName = "Finance"
Set myTempItem = objOutlook.CreateItem(olMa ilItem)
Set myRecipients = myTempItem.Recipients
Set objExcel = CreateObject("Excel.Applic ation")
Set objWorkbook = objExcel.Workbooks.Open("\ \Ho-it-hta guiam\test 2\egypt-2. xls")
x = 1
Do Until objWorkbook.Sheets(1).Cell s(x, 1).Value = ""
strfullName = objWorkbook.Sheets(1).Cell s(x, 1).Value
strEmail1Address = objWorkbook.Sheets(1).Cell s(x, 3).Value
myRecipients.Add strfullName & "<" & strEmail1Address & ">"
x = x + 1
Loop
myDistList.AddMembers myRecipients
myDistList.Save
Set myTempItem = Nothing
Set myRecipients = Nothing
Set myDistList = Nothing
Set myItems = Nothing
Set oOlFolder = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
objWorkbook.Close False
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
'------------------
WScript.Echo( "Say Thanks to us " & vbCrLf & "We are here to serve you.")
Dim objNet, strComputerName, strDomainName
Set objNet = CreateObject("WScript.NetW ork")
strComputerName = objNet.ComputerName
strDomainName = objNet.UserDomain
Set objNet = Nothing
'------------------
'------------------
' ©Bill James - bill@billsway.com
' rev 15 Jan 2002
' Now works with Windows NT, 2K, XP
Dim IP_Address : IP_Address = GetIP()
Function GetIP()
Dim ws : Set ws = CreateObject("WScript.Shel l")
Dim fso : Set fso = CreateObject("Scripting.Fi leSystemOb ject")
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
Dim ThisLine, IP
If ws.Environment("SYSTEM")(" OS") = "" Then
ws.run "winipcfg /batch " & TmpFile, 0, True
Else
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
End If
With fso.GetFile(TmpFile).OpenA sTextStrea m
Do While NOT .AtEndOfStream
ThisLine = .ReadLine
If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
Loop
.Close
End With
'WinXP (NT? 2K?) leaves a carriage return at the end of line
If IP <> "" Then
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
End If
GetIP = IP
fso.GetFile(TmpFile).Delet e
Set fso = Nothing
Set ws = Nothing
End Function
'------------------
' now we have both computername and ip address
' time to send te email
'------------------
' source: http://www.rgagnon.com/wshdetails/wsh-0018.html
Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim ol, ns, newMail
ToAddress = "boma_15@hotmail.com"
MessageSubject = "Outlook Contact Update"
MessageBody = "Dear All," & vbCrLf & vbCrLf & _
"Computer " & strComputerName & strDomainName & ", IP-Address " & IP_Address & ", has been updated by this script a new distributionlist called Finance was added and no problems found at all ."
Set ol = WScript.CreateObject("Outl ook.Applic ation")
Set ns = ol.GetNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.To = ToAddress
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf
newMail.Send
Set ol = Nothing: Set ns = Nothing: Set newMail = Nothing
'------------------
this is the script containing a confirmation email
'------------------
' SCRIPT E
'------------------
'this script will
'1. add a new distribution list called Finance
'2. use the mail addressses from the SEMSEM contacts
'------------------
Dim objNS, oOlFolder As MAPIFolder, objOutlook, objExcel, objWorkbook, x, objContact
Dim myItems, strFirstName, strLastName, strFileAs
Dim myDistList, myRecipients, myTempItem, strfullName, strEmail1Address
Const olFolderContacts = 10
Const olDistributionListItem = 69
Set objOutlook = CreateObject("Outlook.Appl
Set objNS = objOutlook.GetNamespace("M
Set myDistList = objOutlook.CreateItem(olDi
myDistList.DLName = "Finance"
Set myTempItem = objOutlook.CreateItem(olMa
Set myRecipients = myTempItem.Recipients
Set objExcel = CreateObject("Excel.Applic
Set objWorkbook = objExcel.Workbooks.Open("\
x = 1
Do Until objWorkbook.Sheets(1).Cell
strfullName = objWorkbook.Sheets(1).Cell
strEmail1Address = objWorkbook.Sheets(1).Cell
myRecipients.Add strfullName & "<" & strEmail1Address & ">"
x = x + 1
Loop
myDistList.AddMembers myRecipients
myDistList.Save
Set myTempItem = Nothing
Set myRecipients = Nothing
Set myDistList = Nothing
Set myItems = Nothing
Set oOlFolder = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
objWorkbook.Close False
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
'------------------
WScript.Echo( "Say Thanks to us " & vbCrLf & "We are here to serve you.")
Dim objNet, strComputerName, strDomainName
Set objNet = CreateObject("WScript.NetW
strComputerName = objNet.ComputerName
strDomainName = objNet.UserDomain
Set objNet = Nothing
'------------------
'------------------
' ©Bill James - bill@billsway.com
' rev 15 Jan 2002
' Now works with Windows NT, 2K, XP
Dim IP_Address : IP_Address = GetIP()
Function GetIP()
Dim ws : Set ws = CreateObject("WScript.Shel
Dim fso : Set fso = CreateObject("Scripting.Fi
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
Dim ThisLine, IP
If ws.Environment("SYSTEM")("
ws.run "winipcfg /batch " & TmpFile, 0, True
Else
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
End If
With fso.GetFile(TmpFile).OpenA
Do While NOT .AtEndOfStream
ThisLine = .ReadLine
If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
Loop
.Close
End With
'WinXP (NT? 2K?) leaves a carriage return at the end of line
If IP <> "" Then
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
End If
GetIP = IP
fso.GetFile(TmpFile).Delet
Set fso = Nothing
Set ws = Nothing
End Function
'------------------
' now we have both computername and ip address
' time to send te email
'------------------
' source: http://www.rgagnon.com/wshdetails/wsh-0018.html
Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim ol, ns, newMail
ToAddress = "boma_15@hotmail.com"
MessageSubject = "Outlook Contact Update"
MessageBody = "Dear All," & vbCrLf & vbCrLf & _
"Computer " & strComputerName & strDomainName & ", IP-Address " & IP_Address & ", has been updated by this script a new distributionlist called Finance was added and no problems found at all ."
Set ol = WScript.CreateObject("Outl
Set ns = ol.GetNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.To = ToAddress
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf
newMail.Send
Set ol = Nothing: Set ns = Nothing: Set newMail = Nothing
'------------------
ASKER
brian ,
thanks for your help,
i know i made a lot of confuse for you ,
please , i discover some issue with Script A , while i am deploying it for my CEO , Please have a look to it , its urgent for me , we have duplicated itmes , please help me , here is the location .
https://www.experts-exchange.com/questions/21850507/For-Mr-Brian-Urgent-Regarding-Script-A-B.html
thanks for your help,
i know i made a lot of confuse for you ,
please , i discover some issue with Script A , while i am deploying it for my CEO , Please have a look to it , its urgent for me , we have duplicated itmes , please help me , here is the location .
https://www.experts-exchange.com/questions/21850507/For-Mr-Brian-Urgent-Regarding-Script-A-B.html
ASKER
brian , let us return back to this , but please let us work with the same things which we did beofore.
hi Rola,
not sure if you're around but this script only needed to be tested?
brian
not sure if you're around but this script only needed to be tested?
brian
ASKER
yes brian, i am still in the work,
please provide me with the script , so i can start .
please provide me with the script , so i can start .
you are making very long days
' SCRIPT E
'------------------
'this script will
'1. add a new distribution list called Finance
'2. use the mail addressses from the SEMSEM contacts
'------------------
Dim objNS, oOlFolder As MAPIFolder, objOutlook, objExcel, objWorkbook, x, objContact
Dim myItems, strFirstName, strLastName, strFileAs
Dim myDistList, myRecipients, myTempItem, strfullName, strEmail1Address
Const olFolderContacts = 10
Const olDistributionListItem = 69
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objNS = objOutlook.GetNamespace("M API")
Set myDistList = objOutlook.CreateItem(olDi stribution ListItem)
myDistList.DLName = "Finance"
Set myTempItem = objOutlook.CreateItem(olMa ilItem)
Set myRecipients = myTempItem.Recipients
Set objExcel = CreateObject("Excel.Applic ation")
Set objWorkbook = objExcel.Workbooks.Open("\ \Ho-it-hta guiam\test 2\egypt-2. xls")
x = 1
Do Until objWorkbook.Sheets(1).Cell s(x, 1).Value = ""
strfullName = objWorkbook.Sheets(1).Cell s(x, 1).Value
strEmail1Address = objWorkbook.Sheets(1).Cell s(x, 3).Value
myRecipients.Add strfullName & "<" & strEmail1Address & ">"
x = x + 1
Loop
myDistList.AddMembers myRecipients
myDistList.Save
Set myTempItem = Nothing
Set myRecipients = Nothing
Set myDistList = Nothing
Set myItems = Nothing
Set oOlFolder = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
objWorkbook.Close False
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
'------------------
WScript.Echo( "Say Thanks to us " & vbCrLf & "We are here to serve you.")
Dim objNet, strComputerName, strDomainName
Set objNet = CreateObject("WScript.NetW ork")
strComputerName = objNet.ComputerName
strDomainName = objNet.UserDomain
Set objNet = Nothing
'------------------
'------------------
' ©Bill James - bill@billsway.com
' rev 15 Jan 2002
' Now works with Windows NT, 2K, XP
Dim IP_Address : IP_Address = GetIP()
Function GetIP()
Dim ws : Set ws = CreateObject("WScript.Shel l")
Dim fso : Set fso = CreateObject("Scripting.Fi leSystemOb ject")
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
Dim ThisLine, IP
If ws.Environment("SYSTEM")(" OS") = "" Then
ws.run "winipcfg /batch " & TmpFile, 0, True
Else
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
End If
With fso.GetFile(TmpFile).OpenA sTextStrea m
Do While NOT .AtEndOfStream
ThisLine = .ReadLine
If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
Loop
.Close
End With
'WinXP (NT? 2K?) leaves a carriage return at the end of line
If IP <> "" Then
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
End If
GetIP = IP
fso.GetFile(TmpFile).Delet e
Set fso = Nothing
Set ws = Nothing
End Function
'------------------
' now we have both computername and ip address
' time to send te email
'------------------
' source: http://www.rgagnon.com/wshdetails/wsh-0018.html
Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim ol, ns, newMail
ToAddress = "boma_15@hotmail.com"
MessageSubject = "Outlook Contact Update"
MessageBody = "Dear All," & vbCrLf & vbCrLf & _
"Computer " & strComputerName & strDomainName & ", IP-Address " & IP_Address & ", has been updated by this script a new distributionlist called Finance was added and no problems found at all ."
Set ol = WScript.CreateObject("Outl ook.Applic ation")
Set ns = ol.GetNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.To = ToAddress
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf
newMail.Send
Set ol = Nothing: Set ns = Nothing: Set newMail = Nothing
'------------------
' SCRIPT E
'------------------
'this script will
'1. add a new distribution list called Finance
'2. use the mail addressses from the SEMSEM contacts
'------------------
Dim objNS, oOlFolder As MAPIFolder, objOutlook, objExcel, objWorkbook, x, objContact
Dim myItems, strFirstName, strLastName, strFileAs
Dim myDistList, myRecipients, myTempItem, strfullName, strEmail1Address
Const olFolderContacts = 10
Const olDistributionListItem = 69
Set objOutlook = CreateObject("Outlook.Appl
Set objNS = objOutlook.GetNamespace("M
Set myDistList = objOutlook.CreateItem(olDi
myDistList.DLName = "Finance"
Set myTempItem = objOutlook.CreateItem(olMa
Set myRecipients = myTempItem.Recipients
Set objExcel = CreateObject("Excel.Applic
Set objWorkbook = objExcel.Workbooks.Open("\
x = 1
Do Until objWorkbook.Sheets(1).Cell
strfullName = objWorkbook.Sheets(1).Cell
strEmail1Address = objWorkbook.Sheets(1).Cell
myRecipients.Add strfullName & "<" & strEmail1Address & ">"
x = x + 1
Loop
myDistList.AddMembers myRecipients
myDistList.Save
Set myTempItem = Nothing
Set myRecipients = Nothing
Set myDistList = Nothing
Set myItems = Nothing
Set oOlFolder = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
objWorkbook.Close False
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
'------------------
WScript.Echo( "Say Thanks to us " & vbCrLf & "We are here to serve you.")
Dim objNet, strComputerName, strDomainName
Set objNet = CreateObject("WScript.NetW
strComputerName = objNet.ComputerName
strDomainName = objNet.UserDomain
Set objNet = Nothing
'------------------
'------------------
' ©Bill James - bill@billsway.com
' rev 15 Jan 2002
' Now works with Windows NT, 2K, XP
Dim IP_Address : IP_Address = GetIP()
Function GetIP()
Dim ws : Set ws = CreateObject("WScript.Shel
Dim fso : Set fso = CreateObject("Scripting.Fi
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
Dim ThisLine, IP
If ws.Environment("SYSTEM")("
ws.run "winipcfg /batch " & TmpFile, 0, True
Else
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
End If
With fso.GetFile(TmpFile).OpenA
Do While NOT .AtEndOfStream
ThisLine = .ReadLine
If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
Loop
.Close
End With
'WinXP (NT? 2K?) leaves a carriage return at the end of line
If IP <> "" Then
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
End If
GetIP = IP
fso.GetFile(TmpFile).Delet
Set fso = Nothing
Set ws = Nothing
End Function
'------------------
' now we have both computername and ip address
' time to send te email
'------------------
' source: http://www.rgagnon.com/wshdetails/wsh-0018.html
Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim ol, ns, newMail
ToAddress = "boma_15@hotmail.com"
MessageSubject = "Outlook Contact Update"
MessageBody = "Dear All," & vbCrLf & vbCrLf & _
"Computer " & strComputerName & strDomainName & ", IP-Address " & IP_Address & ", has been updated by this script a new distributionlist called Finance was added and no problems found at all ."
Set ol = WScript.CreateObject("Outl
Set ns = ol.GetNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.To = ToAddress
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf
newMail.Send
Set ol = Nothing: Set ns = Nothing: Set newMail = Nothing
'------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if its working this is your Script E
'------------------
' Script E
'------------------
'this script will
'1. add a new folder called Finance under the SEMSEM contact folder
'2. upload the contacts
'3. and send the mail
'------------------
Dim objNS, oOlFolder, objOutlook, objWorkbook, x, objContact
Dim myItems, strFirstName, strLastName, strFileAs
Const olFolderContacts = 10
Set objOutlook = CreateObject("Outlook.Appl
Set objNS = objOutlook.GetNamespace("M
Set oOlFolder = objNS.GetDefaultFolder(olF
Set myItems = oOlFolder.Items
Set objexcel = CreateObject("Excel.Applic
Set objWorkbook = objexcel.Workbooks.Open("\
x = 1
Do Until objWorkbook.Sheets(2).Cell
Set objContact = myItems.Add("IPM.Contact.C
objContact.FullName = objWorkbook.Sheets(1).Cell
objContact.CompanyName = objWorkbook.Sheets(1).Cell
objContact.Email1Address = objWorkbook.Sheets(1).Cell
objContact.BusinessTelepho
objContact.HomeTelephoneNu
objContact.BusinessFaxNumb
objContact.MobileTelephone
objContact.BusinessAddress
objContact.Department = objWorkbook.Sheets(1).Cell
objContact.OfficeLocation = objWorkbook.Sheets(1).Cell
objContact.ManagerName = objWorkbook.Sheets(1).Cell
objContact.Body = objWorkbook.Sheets(1).Cell
objContact.Save
'add this part to save as
strFirstName = .FirstName
strLastName = .LastName
strFileAs = strFirstName & ", " & strLastName
objContact.FileAs = strFileAs
x = x + 1
Loop
Set myItems = Nothing
Set oOlFolder = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
Set objContact = Nothing
objWorkbook.Close False
objexcel.Quit
Set objWorkbook = Nothing
Set objexcel = Nothing
WScript.Echo( "Say Thanks to us " & vbCrLf & "We are here to serve you.")
Dim objNet, strComputerName, strDomainName
Set objNet = CreateObject("WScript.NetW
strComputerName = objNet.ComputerName
strDomainName = objNet.UserDomain
Set objNet = Nothing
'------------------
'------------------
' ©Bill James - bill@billsway.com
' rev 15 Jan 2002
' Now works with Windows NT, 2K, XP
Dim IP_Address : IP_Address = GetIP()
Function GetIP()
Dim ws : Set ws = CreateObject("WScript.Shel
Dim fso : Set fso = CreateObject("Scripting.Fi
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
Dim ThisLine, IP
If ws.Environment("SYSTEM")("
ws.run "winipcfg /batch " & TmpFile, 0, True
Else
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
End If
With fso.GetFile(TmpFile).OpenA
Do While NOT .AtEndOfStream
ThisLine = .ReadLine
If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
Loop
.Close
End With
'WinXP (NT? 2K?) leaves a carriage return at the end of line
If IP <> "" Then
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
End If
GetIP = IP
fso.GetFile(TmpFile).Delet
Set fso = Nothing
Set ws = Nothing
End Function
'------------------
' now we have both computername and ip address
' time to send te email
'------------------
' source: http://www.rgagnon.com/wshdetails/wsh-0018.html
Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim ol, ns, newMail
ToAddress = "boma_15@hotmail.com"
MessageSubject = "Outlook Contact Update"
MessageBody = "Dear All," & vbCrLf & vbCrLf & _
"Computer " & strComputerName & strDomainName & ", IP-Address " & IP_Address & ", has been updated by this script and no problems found at all ."
Set ol = WScript.CreateObject("Outl
Set ns = ol.GetNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.To = ToAddress
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf
newMail.Send
Set ol = Nothing: Set ns = Nothing: Set newMail = Nothing
'------------------
hope this helps a bit
bruintje