rolamohammed
asked on
About Repeating the Script -For Mr. Brian
Dear Brian,
I want really to Thank you for your Great Help.
We deployed your Scripts - Script A & Script B , and we really found that its More than Great.
I want to thank you for all of the Efforts which you made for me and your helping me in My Project.
And its really wonderful that you are here with us in this Communitiy .
In the same time , I have some comments I got it from My manager while I am deploying it infront of him and I want to consult you regarding Our Requirements.
My requirments is divided into ( First Part ) & ( Second Part ).
The First Part of it is ( Adding some modifications to Script A & Script B ), while Second Part is Talking about Write a new Scripts .
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
First Part :-
Q1: Can you Please Modify the Script A & Script B to do the following :-
A. send the Complete Computer Name like, for example
( RolaPC.mydomain.com ) ? Instead of ( Rola
B. Sort All the Contacts Names to start with First Name in ( File as ), instead of Last name.
C. Add any aditional comments under the field ( IM Address ), like His Time Table , His Medicin which he is dealing with it .
If So, can you Please Provide me with the 2 Scripts including this modifications, so I will cut & past it Directly and start using it .
========================== ========== ========== ========== ========== ========== ========== ========== ========== ========== =====
Second Part :-
Q1:- is there any Script ( I will consider it Script C ) you can write to Delete Specific Contacts ( more than 1contact ) ( what will happen if I want to delete 1 contact only do you think the script will be different ) completely after I mention them in the script from Specifc Folder like ( SEMSEM ) and after it delete the Records completely , it will send an E-mail Conatain the Following :-
(1- complete Computer Name like ( Rola.mydomain.com) ).
( 2 - Computer IP-Address ).
3- All the Contacts ( As Full Name ) which has been deleted from the User PC according to the Script which has been excuted .
4- Display message that say the Following : ( All Users Has been Deleted. For any Information Contact US ).
The E-mail should be Like that :-
The following Conatcts has been deleted from ( Rola.mydomain.com ) , IP-Address ( x.x.x.x ):
rola@aaa.com , same@aaa.com , noha@aaa.com .
No Problems at all have been found on This PC.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
Q2:- is there any script ( I will consider it Script D ) you can write to delete Specific Itmes ( more than 1 ) from One Contact In Specifc folder " which is SEMSEM " and replaced it with New information ? . For example, if we have this contact in SEMSEM Folder , her Name is ( NOHA Sameer ), and all of her Information was updated through the excel sheet. And all of here information was like that :-
Full Name : Noha Sameer.
Company Name : EGYSOLUTIONS
E-mail : noha@aaa.com
Business Tel: 002025674377
Business Fax : 0020109876533
Mobile Telephone number : 0102321234
Business Address : Saudi Arabia.
Department : Purchasing
Office Location : Jeddah.
Manager : XXXX
Job Title : ZZZZ
And after 4 months, we have been informed about she has been moved from Egysolutions to TAT.NET & her E-mail Address is DSD@aaa.NET.
So how can we change the specifc records ? What about the Others itmes as well , how can I change them - can you please write the script for them as well ?
Also I want it to send an E-mail with Computer Name & IP-Address & say the Conatcts has been updated.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------
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 gypt-2.xls ") but all the information will be taken from Sheet (2) , not sheet (1) as we wrote in Script A & B.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------
Q3: I will assume that , the Distribution List Has been Created and has some members on it ( 5 users ), and after 3 months , we hired 20 new employees , and we got all of there information. Now we want to write a script ( I will consider it Script F ) to Update the Distribution List without need to create the distribution List ,and take all the New information from the same file ("\\Ho-it-htaguiam\test2\e gypt-2.xls ") but from sheet 2.
I need it also to send an E-mail and send the computer Name and IP-Address and to say " all the New Members of this Distrubtion List has been added to this PC " Computer Name " , IP-address , and no any Problems at all has been found .
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -----
Brian, once again it will be consider as Gift ( big big gift ) from you if you could solve this requirments, but I want to confirm that , you did your best and you satisfy my requirments , and you were more than greate with me , and I have no Problems at all in the prevouise scripts ( A ) or ( B ).
And I am repeating, if you have time , try to solve my extra requirements and I will be very grateful for you & very thankful for you .
Best regards,
Rola
Egypt- Land of civilizations ( 7000 years of civilizations ) :)) .
<email and IP address edited by GranMod>
I want really to Thank you for your Great Help.
We deployed your Scripts - Script A & Script B , and we really found that its More than Great.
I want to thank you for all of the Efforts which you made for me and your helping me in My Project.
And its really wonderful that you are here with us in this Communitiy .
In the same time , I have some comments I got it from My manager while I am deploying it infront of him and I want to consult you regarding Our Requirements.
My requirments is divided into ( First Part ) & ( Second Part ).
The First Part of it is ( Adding some modifications to Script A & Script B ), while Second Part is Talking about Write a new Scripts .
--------------------------
First Part :-
Q1: Can you Please Modify the Script A & Script B to do the following :-
A. send the Complete Computer Name like, for example
( RolaPC.mydomain.com ) ? Instead of ( Rola
B. Sort All the Contacts Names to start with First Name in ( File as ), instead of Last name.
C. Add any aditional comments under the field ( IM Address ), like His Time Table , His Medicin which he is dealing with it .
If So, can you Please Provide me with the 2 Scripts including this modifications, so I will cut & past it Directly and start using it .
==========================
Second Part :-
Q1:- is there any Script ( I will consider it Script C ) you can write to Delete Specific Contacts ( more than 1contact ) ( what will happen if I want to delete 1 contact only do you think the script will be different ) completely after I mention them in the script from Specifc Folder like ( SEMSEM ) and after it delete the Records completely , it will send an E-mail Conatain the Following :-
(1- complete Computer Name like ( Rola.mydomain.com) ).
( 2 - Computer IP-Address ).
3- All the Contacts ( As Full Name ) which has been deleted from the User PC according to the Script which has been excuted .
4- Display message that say the Following : ( All Users Has been Deleted. For any Information Contact US ).
The E-mail should be Like that :-
The following Conatcts has been deleted from ( Rola.mydomain.com ) , IP-Address ( x.x.x.x ):
rola@aaa.com , same@aaa.com , noha@aaa.com .
No Problems at all have been found on This PC.
--------------------------
Q2:- is there any script ( I will consider it Script D ) you can write to delete Specific Itmes ( more than 1 ) from One Contact In Specifc folder " which is SEMSEM " and replaced it with New information ? . For example, if we have this contact in SEMSEM Folder , her Name is ( NOHA Sameer ), and all of her Information was updated through the excel sheet. And all of here information was like that :-
Full Name : Noha Sameer.
Company Name : EGYSOLUTIONS
E-mail : noha@aaa.com
Business Tel: 002025674377
Business Fax : 0020109876533
Mobile Telephone number : 0102321234
Business Address : Saudi Arabia.
Department : Purchasing
Office Location : Jeddah.
Manager : XXXX
Job Title : ZZZZ
And after 4 months, we have been informed about she has been moved from Egysolutions to TAT.NET & her E-mail Address is DSD@aaa.NET.
So how can we change the specifc records ? What about the Others itmes as well , how can I change them - can you please write the script for them as well ?
Also I want it to send an E-mail with Computer Name & IP-Address & say the Conatcts has been updated.
--------------------------
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
--------------------------
Q3: I will assume that , the Distribution List Has been Created and has some members on it ( 5 users ), and after 3 months , we hired 20 new employees , and we got all of there information. Now we want to write a script ( I will consider it Script F ) to Update the Distribution List without need to create the distribution List ,and take all the New information from the same file ("\\Ho-it-htaguiam\test2\e
I need it also to send an E-mail and send the computer Name and IP-Address and to say " all the New Members of this Distrubtion List has been added to this PC " Computer Name " , IP-address , and no any Problems at all has been found .
--------------------------
Brian, once again it will be consider as Gift ( big big gift ) from you if you could solve this requirments, but I want to confirm that , you did your best and you satisfy my requirments , and you were more than greate with me , and I have no Problems at all in the prevouise scripts ( A ) or ( B ).
And I am repeating, if you have time , try to solve my extra requirements and I will be very grateful for you & very thankful for you .
Best regards,
Rola
Egypt- Land of civilizations ( 7000 years of civilizations ) :)) .
<email and IP address edited by GranMod>
ASKER
thanks brian ,
take your time
take your time
ASKER
what do you mean by chaging E-mail & IP Address ?
its fake IP-Address, i put it from my mind . that is it .
ASKER
yes i made .
i hope you are not make a joke over me because i asked you & brian many questions .
i hope you are not make a joke over me because i asked you & brian many questions .
Hi Rola,
For this question i will only do the first part, this whole thing is looking more like work and i have more then enough of that :)
You can ask other questions maybe even in the Outlook TA to have input from others, be sure to add your previous question links [the scripts A and B] to it so others who might want to help you can get a head start by reading what the scripts are about.
I need a bit more information on the additional comments are these in the excel sheet with the other contact items?
Brian
For this question i will only do the first part, this whole thing is looking more like work and i have more then enough of that :)
You can ask other questions maybe even in the Outlook TA to have input from others, be sure to add your previous question links [the scripts A and B] to it so others who might want to help you can get a head start by reading what the scripts are about.
I need a bit more information on the additional comments are these in the excel sheet with the other contact items?
Brian
ASKER
Thanks brian,
But i said to you its not work at all, and i am really looking for your help becaue you are the only one who worked with me since along time in this issue, so i prefear you to work with me on it.
anyway, where should i Post it, as long as you did not have time , please tell me i could not understand you .
i need a bit more info on this part
---------
First Part :-
A. send the Complete Computer Name like, for example ( RolaPC.mydomain.com ) ? Instead of ( Rola
B. Sort All the Contacts Names to start with First Name in ( File as ), instead of Last name.
C. Add any aditional comments under the field ( IM Address ), like His Time Table , His Medicin which he is dealing with it
---------
for C. i need to know if these comments are in the excel sheet with the other contact items?
---------
First Part :-
A. send the Complete Computer Name like, for example ( RolaPC.mydomain.com ) ? Instead of ( Rola
B. Sort All the Contacts Names to start with First Name in ( File as ), instead of Last name.
C. Add any aditional comments under the field ( IM Address ), like His Time Table , His Medicin which he is dealing with it
---------
for C. i need to know if these comments are in the excel sheet with the other contact items?
ASKER
Thanks brian for your help.
Yes, its there and i want to add it under the IM Address feild .
thanks for your help.
-------------------------- ---------- ---
brian , do a favour for me, and try to have time to look to my second part, even for example , every day we will take one question from second Part, i am not need it Now - second Part .
Please brian , do a favour for me and try to help me as much as you can in this matter , Please Please Please Please Please , because i trust you .
Yes, its there and i want to add it under the IM Address feild .
thanks for your help.
--------------------------
brian , do a favour for me, and try to have time to look to my second part, even for example , every day we will take one question from second Part, i am not need it Now - second Part .
Please brian , do a favour for me and try to help me as much as you can in this matter , Please Please Please Please Please , because i trust you .
ASKER
brian
hi, good morninig, is there any news , are we going forward ??
hi, good morninig, is there any news , are we going forward ??
i'll be back in a little while posting a script
ASKER
thanks man ,
i hope the best for you .
i hope the best for you .
this is a three part post
i have 2 new scripts one PART A and the other PART B
this requirement
>>>C. Add any aditional comments under the field ( IM Address ), like His Time Table , His Medicin which he is dealing with it
is placed under the contact body i cannot find something called IM Address in the contact fields, and i assumed it was in the excel file in the column besides the manager name column 12
i have 2 new scripts one PART A and the other PART B
this requirement
>>>C. Add any aditional comments under the field ( IM Address ), like His Time Table , His Medicin which he is dealing with it
is placed under the contact body i cannot find something called IM Address in the contact fields, and i assumed it was in the excel file in the column besides the manager name column 12
'------------------
' PART A
'------------------
'this script will
'1. add 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 ication")
Set objNS = objOutlook.GetNamespace("M API")
Set oOlFolder = objNS.GetDefaultFolder(olF olderConta cts).Folde rs.Add("SE MSEM")
Set myItems = oOlFolder.Items
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 = ""
Set objContact = myItems.Add("IPM.Contact.C TXContacts ")
objContact.FullName = objWorkbook.Sheets(1).Cell s(x, 1).Value
objContact.CompanyName = objWorkbook.Sheets(1).Cell s(x, 2).Value
objContact.Email1Address = objWorkbook.Sheets(1).Cell s(x, 3).Value
objContact.BusinessTelepho neNumber = objWorkbook.Sheets(1).Cell s(x, 4).Value
objContact.HomeTelephoneNu mber = objWorkbook.Sheets(1).Cell s(x, 5).Value
objContact.BusinessFaxNumb er = objWorkbook.Sheets(1).Cell s(x, 6).Value
objContact.MobileTelephone Number = objWorkbook.Sheets(1).Cell s(x, 7).Value
objContact.BusinessAddress = objWorkbook.Sheets(1).Cell s(x, 8).Value
objContact.Department = objWorkbook.Sheets(1).Cell s(x, 9).Value
objContact.OfficeLocation = objWorkbook.Sheets(1).Cell s(x, 10).Value
objContact.ManagerName = objWorkbook.Sheets(1).Cell s(x, 11).Value
objContact.Body = objWorkbook.Sheets(1).Cell s(x, 12).Value
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 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 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
'------------------
' PART A
'------------------
'this script will
'1. add 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(1).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
'------------------
'------------------
' PART B
'------------------
'this script will
'1. get 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 ication")
Set objNS = objOutlook.GetNamespace("M API")
Set oOlFolder = objNS.GetDefaultFolder(olF olderConta cts).Folde rs("SEMSEM ")
Set myItems = oOlFolder.Items
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 = ""
Set objContact = myItems.Add("IPM.Contact.C TXContacts ")
objContact.FullName = objWorkbook.Sheets(1).Cell s(x, 1).Value
objContact.CompanyName = objWorkbook.Sheets(1).Cell s(x, 2).Value
objContact.Email1Address = objWorkbook.Sheets(1).Cell s(x, 3).Value
objContact.BusinessTelepho neNumber = objWorkbook.Sheets(1).Cell s(x, 4).Value
objContact.HomeTelephoneNu mber = objWorkbook.Sheets(1).Cell s(x, 5).Value
objContact.BusinessFaxNumb er = objWorkbook.Sheets(1).Cell s(x, 6).Value
objContact.MobileTelephone Number = objWorkbook.Sheets(1).Cell s(x, 7).Value
objContact.BusinessAddress = objWorkbook.Sheets(1).Cell s(x, 8).Value
objContact.Department = objWorkbook.Sheets(1).Cell s(x, 9).Value
objContact.OfficeLocation = objWorkbook.Sheets(1).Cell s(x, 10).Value
objContact.ManagerName = objWorkbook.Sheets(1).Cell s(x, 11).Value
objContact.Body = objWorkbook.Sheets(1).Cell s(x, 12).Value
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 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 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
'------------------
' PART B
'------------------
'this script will
'1. get 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(1).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
'------------------
ASKER
Thanks Brian ,
i will try to deploy them, and i will come back to you on EE.
is there any way around from you to see my Second Part ?
or is there any one interrested to see Second Part for me ?
thanks .
i will try to deploy them, and i will come back to you on EE.
is there any way around from you to see my Second Part ?
or is there any one interrested to see Second Part for me ?
thanks .
for your second part
Script C
of course deleting contacts is also possible and the part for sending you already have just need to change the message body
Script D
This is a bit more difficult because you have to look up the contactitem in the folder first and then go through the properties to change them
Script E
I assume you mean the distribution list under SEMSEM should be a contactfolder with new contact info like the ones in SEMSEM
Script F
Updating is just like Script B only for another folder
If i where you i would do the following with all these questions
For each script ask a seperate [this is very important] 50 or 100 point question in the VB Area as you did for this question make it very clear what you need as you did above and put a pointer to the original question with script A and B this will make it easier for other people around to pick it up and work from there
Ask each question when you have finished the previous one this wil make it easier to manage
I know you can ask 500 point questions for each but with most of the work already done that is not needed
Script C
of course deleting contacts is also possible and the part for sending you already have just need to change the message body
Script D
This is a bit more difficult because you have to look up the contactitem in the folder first and then go through the properties to change them
Script E
I assume you mean the distribution list under SEMSEM should be a contactfolder with new contact info like the ones in SEMSEM
Script F
Updating is just like Script B only for another folder
If i where you i would do the following with all these questions
For each script ask a seperate [this is very important] 50 or 100 point question in the VB Area as you did for this question make it very clear what you need as you did above and put a pointer to the original question with script A and B this will make it easier for other people around to pick it up and work from there
Ask each question when you have finished the previous one this wil make it easier to manage
I know you can ask 500 point questions for each but with most of the work already done that is not needed
ASKER
thanks brian ,
i am appoligize for inconvince has been done, i am still new to EE.
as far as i know i will make each script in each question and i will put 100 point to it , instead of put all of my questions one time .
once agian , please accept my applogize and for time been i will try to do it as you want ,
many thanks for your help.
please allow me to add another question alone .
i am appoligize for inconvince has been done, i am still new to EE.
as far as i know i will make each script in each question and i will put 100 point to it , instead of put all of my questions one time .
once agian , please accept my applogize and for time been i will try to do it as you want ,
many thanks for your help.
please allow me to add another question alone .
ASKER
yes brian , i made it as per your request.
i hope if you can have time to look to it
i hope if you can have time to look to it
Hi Rola,
Its really no problem, EE is a great resource for us all.
But as most of the people answering questions here i'm a volunteer so time is split between other things
Just let me know if the scripts in this question are working ok, there could be problems with the firstname lastname order didn't test that much
Brian
Its really no problem, EE is a great resource for us all.
But as most of the people answering questions here i'm a volunteer so time is split between other things
Just let me know if the scripts in this question are working ok, there could be problems with the firstname lastname order didn't test that much
Brian
ASKER
Ok,
brian , i will test it , but i am sure 100 % , you are doing every thing is correct.
you are more than master, i like your way.
"
I know you are volunteer and you are split time between other things " .
and i know i become over you in alot of things . ( which i do not have right to do that ) .
but frankely speaking, you are the only one who helped me , and to be honest with you, my manager promise me i will have bouns if i could do that , that is why i asked you & i trust you .
and i am really lokking for your help in theses inputs for Second Part.
so if you have time , and you are in a good mode ,, pllease do not forget your littile girl friend ROLA From Egypt her Request , Please .
once agian thanks for your support, and i will test & i wil come back to you .
brian , i will test it , but i am sure 100 % , you are doing every thing is correct.
you are more than master, i like your way.
"
I know you are volunteer and you are split time between other things " .
and i know i become over you in alot of things . ( which i do not have right to do that ) .
but frankely speaking, you are the only one who helped me , and to be honest with you, my manager promise me i will have bouns if i could do that , that is why i asked you & i trust you .
and i am really lokking for your help in theses inputs for Second Part.
so if you have time , and you are in a good mode ,, pllease do not forget your littile girl friend ROLA From Egypt her Request , Please .
once agian thanks for your support, and i will test & i wil come back to you .
ASKER
Brian ,
Hi man,
its still not working & its display this error message :-
line : 43
Char : 8
Error : invalid or unqualified refrence
Code : 800A01f9
Hi man,
its still not working & its display this error message :-
line : 43
Char : 8
Error : invalid or unqualified refrence
Code : 800A01f9
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes brian ,
the Script is working ,
i am waiting for Script B.
but in the script B, we will not add the Folder at all which is " SEMSEM ", but it will completely update the list .
thanks for your support man .
i am waiting .
ASKER
Yes brian , but its display this message :-
Dear All,
Computer IT-O-BAHAKEEMKABHOLDING, IP-Address 172.16.2.148, has been updated by this script and no problems found at all .
but i need the PC Name to be like that :-
IT-O-BAHAKEEM.KABHOLDING.C OM
not as one word , so how can we modify it in Script A & Script B.
thanks for your help.
Dear All,
Computer IT-O-BAHAKEEMKABHOLDING, IP-Address 172.16.2.148, has been updated by this script and no problems found at all .
but i need the PC Name to be like that :-
IT-O-BAHAKEEM.KABHOLDING.C
not as one word , so how can we modify it in Script A & Script B.
thanks for your help.
i forgot a few things in the domain name
'------------------
' Script A
'------------------
'this script will
'1. add 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 ication")
Set objNS = objOutlook.GetNamespace("M API")
Set oOlFolder = objNS.GetDefaultFolder(olF olderConta cts).Folde rs.Add("SE MSEM")
Set myItems = oOlFolder.Items
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 = ""
Set objContact = myItems.Add("IPM.Contact.C TXContacts ")
objContact.FullName = objWorkbook.Sheets(1).Cell s(x, 1).Value
objContact.CompanyName = objWorkbook.Sheets(1).Cell s(x, 2).Value
objContact.Email1Address = objWorkbook.Sheets(1).Cell s(x, 3).Value
objContact.BusinessTelepho neNumber = objWorkbook.Sheets(1).Cell s(x, 4).Value
objContact.HomeTelephoneNu mber = objWorkbook.Sheets(1).Cell s(x, 5).Value
objContact.BusinessFaxNumb er = objWorkbook.Sheets(1).Cell s(x, 6).Value
objContact.MobileTelephone Number = objWorkbook.Sheets(1).Cell s(x, 7).Value
objContact.BusinessAddress = objWorkbook.Sheets(1).Cell s(x, 8).Value
objContact.Department = objWorkbook.Sheets(1).Cell s(x, 9).Value
objContact.OfficeLocation = objWorkbook.Sheets(1).Cell s(x, 10).Value
objContact.ManagerName = objWorkbook.Sheets(1).Cell s(x, 11).Value
objContact.Body = objWorkbook.Sheets(1).Cell s(x, 12).Value
objContact.Save
'add this part to save as
strFirstName = objContact.FirstName
strLastName = objContact.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 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 & ".com" & ", IP-Address " & IP_Address & ", has been updated by this script 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 A
'------------------
'this script will
'1. add 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(1).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 = objContact.FirstName
strLastName = objContact.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 & ".com" & ", 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
'------------------
'------------------
' Script B
'------------------
'this script will
'1. add 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 ication")
Set objNS = objOutlook.GetNamespace("M API")
Set oOlFolder = objNS.GetDefaultFolder(olF olderConta cts).Folde rs("SEMSEM ")
Set myItems = oOlFolder.Items
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 = ""
Set objContact = myItems.Add("IPM.Contact.C TXContacts ")
objContact.FullName = objWorkbook.Sheets(1).Cell s(x, 1).Value
objContact.CompanyName = objWorkbook.Sheets(1).Cell s(x, 2).Value
objContact.Email1Address = objWorkbook.Sheets(1).Cell s(x, 3).Value
objContact.BusinessTelepho neNumber = objWorkbook.Sheets(1).Cell s(x, 4).Value
objContact.HomeTelephoneNu mber = objWorkbook.Sheets(1).Cell s(x, 5).Value
objContact.BusinessFaxNumb er = objWorkbook.Sheets(1).Cell s(x, 6).Value
objContact.MobileTelephone Number = objWorkbook.Sheets(1).Cell s(x, 7).Value
objContact.BusinessAddress = objWorkbook.Sheets(1).Cell s(x, 8).Value
objContact.Department = objWorkbook.Sheets(1).Cell s(x, 9).Value
objContact.OfficeLocation = objWorkbook.Sheets(1).Cell s(x, 10).Value
objContact.ManagerName = objWorkbook.Sheets(1).Cell s(x, 11).Value
objContact.Body = objWorkbook.Sheets(1).Cell s(x, 12).Value
objContact.Save
'add this part to save as
strFirstName = objContact.FirstName
strLastName = objContact.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 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 & ".com" & ", IP-Address " & IP_Address & ", has been updated by this script 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 B
'------------------
'this script will
'1. add 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(1).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 = objContact.FirstName
strLastName = objContact.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 & ".com" & ", 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
'------------------
ASKER
Yes Brian ,
its working .
many thanks for your help.
Please try to help me in the other scripts as well, i want to finish from them if you can .
Script C, D, E , F
many thanks for your Help .
never post real mail addresses on EE it will deliver you a lot of spam in the long run, i've asked a moderator to remove them from your question
see : https://www.experts-exchange.com/questions/21844701/URGENT-please-remove-mail-address-from-this-question.html
for your question i'm going to read and will be back in a little while
Brian