This sample demonstrates how to use the named pipe of the Info service to update contact information.
File UpdateContact.vbs used in this sample is located in the folder:
C:\Program Files\CodeSegment\SMS Studio\Samples\InfoService
Upon receiving an incoming message, the script UpdateContact.vbs updates the contact's name, adds the contact into a predefined group and sends back an appropriate reply to the contact.
How to run this sample
Source code
The contents of the UpdateContact.vbs file:
'-------------------------------------------------------------------------------------------------------------------------------
' This script demonstrates how to update contact information in Address Book.
' WARNING: Error checking omitted for clarity.
'
' Use the following application parameters in the Info Rule dialog:
' "%PipeName%" "%MsgID%" "%MsgFrom%" "%P%" "FRIENDS"
'-------------------------------------------------------------------------------------------------------------------------------
if WScript.Arguments.Count = 5 then
' Collect arguments
PipeName = WScript.Arguments(0) ' Pipe name
MsgID = WScript.Arguments(1) ' Message ID
ContactPhone = WScript.Arguments(2) ' Contact phone
ContactName = WScript.Arguments(3) ' Contact name
ContactGroup = WScript.Arguments(4) ' Contact group
if PipeName <> "" then ' Pipe name must be specified in the Info Setup dialog
set fso = CreateObject("Scripting.FileSystemObject")
set pipe = fso.CreateTextFile("\\.\pipe\" & PipeName) ' Open the pipe instance
pipe.WriteLine("Contact: " & ContactPhone)
pipe.WriteLine("Name: " & ContactName)
pipe.WriteLine("AddGroup: " & ContactGroup)
pipe.WriteLine("<Update>") ' Update contact
pipe.WriteLine("ReplyToID: " & MsgID)
pipe.WriteLine("Text: Thanks for updating your name.")
pipe.WriteLine("<Send>") ' Send the message
pipe.Close ' Close the pipe instance
WScript.Quit(0) ' Success
else
MsgBox "Error: Pipe name is missing.", vbCritical, "SMS Studio Update Contact Sample"
WScript.Quit(1) ' Error
end if
else
MsgBox "Error: Wrong number of arguments.", vbCritical, "SMS Studio Update Contact Sample"
WScript.Quit(1) ' Error
end if
'-------------------------------------------------------------------------------------------------------------------------------
' Copyright (c) 2002-2009 CodeSegment. All rights reserved. http://www.codesegment.com/
'-------------------------------------------------------------------------------------------------------------------------------
| Copyright © 2002-2010 CodeSegment. All rights reserved. |