PutItem Method


Put specified field.

long PutItem(
	[in] BSTR Key, 
	[in] BSTR Value
)

Parameters

Key

The key name of field of contact. The following key name are valid. "quickname", "firstname", "lastname", "email", "workemail", "otheremail", "personnumber", "businessnumber", "mobilenumber", "pagernumber", "faxnumber", "othernumber", "personaddress", "personcity", "personstate", "personcountry", "personzipcode", "company", "businessaddress", "businesscity", "businessstate", "businesscountry", "businesszipcode", "birthday", "website"

Value

The value of specified field.

Return Value

Return value is zero if this method succeeds; otherwise return value is non-zero.

Usage Example

Dim server, user, password, requestAddr
server = "localhost"
user = "hunter@emailarchitect.net"
password = "mypassword"
requestAddr = "192.168.0.1"

Dim oSvr
Set oSvr = CreateObject("EmailArchitectObjects.ServerRoot")
r = oSvr.Connect( server, user, password, 0, requestAddr )
If r <> 0 Then
  WScript.Echo( "connect server failed!" )
  WScript.Quit
End If

Dim oDomains, oDomain
Set oDomains = oSvr.DomainCollection
Set oDomain = oDomains.Items(CStr(oSvr.Domain)) 

Dim oUsers, oUser
Set oUsers = oDomain.UserCollection
Set oUser = oUsers.Items(CStr(oSvr.User))

Dim oContacts, oContact
Set oContacts = oUser.ContactCollection
'search contact which has email address "test@emailarchitect.net" and change it
Dim i, nCount
nCount = oContacts.Count
For i = 0 To nCount-1
  Set oContact = oContacts.Items(CLng(i))
  If LCase(oContact.GetItem("email")) = "test@emailarchitect.net" Then
    Exit For
  End If
  Set oContact = Nothing
Next

If oContact Is Nothing Then
  WScript.Echo "no contact found"
  WScript.Quit
End If

Dim cid
cid = oContact.GetItem("cid")
oContact.PutItem "email", "tester@emailarchitect" 
oContacts.Items(CStr(cid)) = oContact
oContacts.Update