rolamohammed
asked on
Deleted specific Itmes from one contact in specific folder
Dear All,
refrence to my request, in this URL :-
https://www.experts-exchange.com/questions/21844678/About-Repeating-the-Script-For-Mr-Brian.html
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.
--------------------------
ASKER
No, what i mean is ,
the script take the information from Shared Folder over Network on Excel Sheet and then put in the user side .
did you understand me .
ASKER
brain
is there any news about
is there any news about
ASKER
Brian,
Good Morning , is there any News regarding it .
Hi Rola
if i understand this correctly the script needs to read from an excel file the updated items for the contacts in the SEMSEM folder
does the excel sheet look the same as the original SCRIPT A excel sheet1?
and how do you mark a contact for deletion or change of the items only?
Brian
if i understand this correctly the script needs to read from an excel file the updated items for the contacts in the SEMSEM folder
does the excel sheet look the same as the original SCRIPT A excel sheet1?
and how do you mark a contact for deletion or change of the items only?
Brian
ASKER
Hi Brian ,
this is ROLA agian from Egypt.
Can you imagin, i am still in the work alone with my self , testing and deploying your scripts .
its here now 22:15 PM Local time in Egypt, and this night i think its very very very very Hot & cloudy , and the weather is bad.
anyway,
YES, you understand me correctly .
but frankly speaking, provide me with the best way from your point of view , i need to consult you in this , please help me if was my idea is wrong , and give me your recommendation or the bestway from your point of view brian .
its too hot man here, i will have drink now .\
well then out weather is a bit better, cool and a few clouds its 21.30 here so we're only 1 hour seperated
about the script
yes i would use the same format for updates or deletions it makes reusing the script easier, only one small addition for 2 columns at the end one for marking a deletion and one for marking an update
if the script is looping through the contacts it will look at the deletion column and check if it is marked if it is clear then it will check the update column to see if the contact must be updated
if this is ok with you i'll write the script based on SCRIPT A
about the script
yes i would use the same format for updates or deletions it makes reusing the script easier, only one small addition for 2 columns at the end one for marking a deletion and one for marking an update
if the script is looping through the contacts it will look at the deletion column and check if it is marked if it is clear then it will check the update column to see if the contact must be updated
if this is ok with you i'll write the script based on SCRIPT A
This is is SCRIPT D, i use the same worksheet layout as in SCRIPT A with 2 new columns
column 13 has a 1 or nothing to mark a contact for deletion
column 14 has a 1 or nothing to mark a contact for update
'------------------
' SCRIPT D
'------------------
'this script will
'1. lookup contacts in the SEMSEM folder
'2. if founzd
'3. and send the mail
'------------------
Dim objNS, oOlFolder As MAPIFolder, objOutlook, objExcel, objWorkbook, x, objContact As Outlook.ContactItem
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 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 = oOlFolder.Items.Find("[Ful lName] = "" & objWorkbook.Sheets(1).Cell s(x, 1).Value & """)
' first check the delete column assuming column 13 in the worksheet
If objWorkbook.Sheets(1).Cell s(x, 13).Value = 1 Then
objContact.Delete
End If
' check the update column assuming column 14 in the worksheet
If objWorkbook.Sheets(1).Cell s(x, 14).Value = 1 Then
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
End If
x = x + 1
Loop
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
Dim IP_Address: IP_Address = 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
'------------------
' 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
'------------------
column 13 has a 1 or nothing to mark a contact for deletion
column 14 has a 1 or nothing to mark a contact for update
'------------------
' SCRIPT D
'------------------
'this script will
'1. lookup contacts in the SEMSEM folder
'2. if founzd
'3. and send the mail
'------------------
Dim objNS, oOlFolder As MAPIFolder, objOutlook, objExcel, objWorkbook, x, objContact As Outlook.ContactItem
Const olFolderContacts = 10
Set objOutlook = CreateObject("Outlook.Appl
Set objNS = objOutlook.GetNamespace("M
Set oOlFolder = objNS.GetDefaultFolder(olF
Set objExcel = CreateObject("Excel.Applic
Set objWorkbook = objExcel.Workbooks.Open("\
x = 1
Do Until objWorkbook.Sheets(1).Cell
Set objContact = oOlFolder.Items.Find("[Ful
' first check the delete column assuming column 13 in the worksheet
If objWorkbook.Sheets(1).Cell
objContact.Delete
End If
' check the update column assuming column 14 in the worksheet
If objWorkbook.Sheets(1).Cell
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
End If
x = x + 1
Loop
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
Dim IP_Address: IP_Address = 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
'------------------
' 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
Hi brian ,
this is Rola from Egypt again .
Actually , i could not understand what do you mean by this :-
" yes i would use the same format for updates or deletions it makes reusing the script easier, only one small addition for 2 columns at the end one for marking a deletion and one for marking an update
if the script is looping through the contacts it will look at the deletion column and check if it is marked if it is clear then it will check the update column to see if the contact must be updated "
Can you please expalin to me, because i could not understand you brian .
Rola- Egypt
2:00 AM Local Time , Egypt
Goodmorning Rola,
When you have contacts (1 or more) use the same setup for a sheet as the original egypt-2.xls.
But insert 2 new columns at the end besides the objWorkbook.Sheets(1).Cell s(x, 12).Value, contact body which is now Column 12.
Column 13 is for deletions
Column 14 is for updates
The script will check column 13 and 14 what to do with the contact
Brian
When you have contacts (1 or more) use the same setup for a sheet as the original egypt-2.xls.
But insert 2 new columns at the end besides the objWorkbook.Sheets(1).Cell
Column 13 is for deletions
Column 14 is for updates
The script will check column 13 and 14 what to do with the contact
Brian
ASKER
Yes Brian ,
so if we have Egypt-2.xls file, i will add only 2 columns only .
so what should i wrote in these cloums , exactly ? can you expalin to me more
so if we have Egypt-2.xls file, i will add only 2 columns only .
so what should i wrote in these cloums , exactly ? can you expalin to me more
if a contact must be deleted then fill a 1 in column 13 else leave it empty
if a contact must be updated then fill a 1 in column 14 else leave it empty
if a contact must be updated then fill a 1 in column 14 else leave it empty
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 CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi rolamohammed,
do you have a file where the contact items to delete are listed? i mean how must the script determine which contact items form which contact to delete?
bruintje