Contacts - OL2ME

Discussion for developers using MailEnable.
Post Reply
sunpost
Posts: 438
Joined: Wed Sep 04, 2002 3:04 pm

Contacts - OL2ME

Post by sunpost »

below is a script that imports contacts from OL to ME.
a few things to consider when using this:
  • Standard Version: 1.606
    Professional Version: 1.104
    OL2002
    WinXP PRO SP1
    Client-side vbscript - no netscrap, internet exploder only.
    Low security zone a must to get to get the Outlook data.
    Postoffice, User Name, and Password are required on the form.
    A GUID is used to name the VCF file - if you run this multiple times, the number of contacts may start to pile up.
    I tested with 17 contacts - unsure what happens with a big load.
good luck!

Code: Select all

<%@ LANGUAGE="VBSCRIPT" %> 
<% Option Explicit %> 
<html>
<head>
<title>Contacts - OL2ME</title>
</head>
<body>
<%
Dim i
Dim oContact

If Request.Form("S") = "Process" Then 
	Response.Write "Processing " & Request.Form("RC") & " records...<br>" & vbCrLf
	For i = 1 To Request.Form("RC")
		Response.Write i & " - " & Request.Form("E" & i) & "<br>" & vbCrLf
		Set oContact = CreateObject("MEWebMail.Contact")
		oContact.PostOffice = Request("PO")
		oContact.Username = Request("UN")
		oContact.Password = Request("PS")
		oContact.MessageID = Replace(mid(Server.createobject("scriptlet.typelib").guid,2,36),"-","") & ".VCF"
		oContact.RelativeFolderPath = "\Contacts"
		oContact.EMail = Request("E" & i)
		oContact.LastName = Request("LN" & i)
		oContact.FirstName = Request("FN" & i)
		oContact.Title = Request("T" & i)
		oContact.MiddleName = Request("MN" & i)
		oContact.FullName = Request("FU" & i)
		oContact.NickName = Request("NN" & i)
		oContact.PhoneW = Request("PW" & i)
		oContact.PhoneH = Request("PH" & i)
		oContact.PhoneM = Request("PM" & i)
		oContact.Business = Request("B" & i)
		oContact.Department = Request("D" & i)
		oContact.SaveContact
		Set oContact = Nothing
	Next
	Response.Write "</body>" & vbCrLf & _
				   "</html>" & vbCrLf
	Response.End
End If
%>		
<form method="POST">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
    <td nowrap>email1address&nbsp;</td>
    <td nowrap>LastName&nbsp;</td>
    <td nowrap>FirstName&nbsp;</td>
    <td nowrap>JobTitle&nbsp;</td>
    <td nowrap>MiddleName&nbsp;</td>
    <td nowrap>FullName&nbsp;</td>
    <td nowrap>NickName&nbsp;</td>
    <td nowrap>BusinessTelephoneNumber&nbsp;</td>
    <td nowrap>HomeTelephoneNumber&nbsp;</td>
    <td nowrap>MobileTelephoneNumber&nbsp;</td>
    <td nowrap>CompanyName&nbsp;</td>
    <td nowrap>Department&nbsp;</td>
  </tr>
<script language="vbscript">
Dim objOutlook
Dim objOLNameSpace
Dim objOLContacts
Dim objOLContactItems
Dim i
Dim j

Set objOutlook = CreateObject("Outlook.Application")
Set objOLNameSpace = objOutlook.GetNameSpace("MAPI")
Set objOLContacts = objOLNameSpace.GetDefaultFolder(10)
Set objOLContactItems = objOLContacts.Items

j = 1
for each i in objOLContactItems 
	Document.Write "<tr>"
 	Document.Write "<td nowrap><input type=""text"" name=""E" & j & """ value=""" & i.email1address & """></td>"
 	Document.Write "<td nowrap><input type=""text"" name=""LN" & j & """ value=""" & i.LastName & """></td>"
 	Document.Write "<td nowrap><input type=""text"" name=""FN" & j & """ value=""" & i.FirstName & """></td>"
	Document.Write "<td nowrap><input type=""text"" name=""T" & j & """ value=""" & i.JobTitle & """></td>"
	Document.Write "<td nowrap><input type=""text"" name=""MN" & j & """ value=""" & i.MiddleName & """></td>"
	Document.Write "<td nowrap><input type=""text"" name=""FU" & j & """ value=""" & i.FullName & """></td>"
	Document.Write "<td nowrap><input type=""text"" name=""NN" & j & """ value=""" & i.NickName & """></td>"
	Document.Write "<td nowrap><input type=""text"" name=""PW" & j & """ value=""" & i.BusinessTelephoneNumber & """></td>"
 	Document.Write "<td nowrap><input type=""text"" name=""PH" & j & """ value=""" & i.HomeTelephoneNumber & """></td>"
 	Document.Write "<td nowrap><input type=""text"" name=""PM" & j & """ value=""" & i.MobileTelephoneNumber & """></td>"
	Document.Write "<td nowrap><input type=""text"" name=""B" & j & """ value=""" & i.CompanyName & """></td>"
	Document.Write "<td nowrap><input type=""text"" name=""D" & j & """ value=""" & i.Department & """></td>"
	Document.Write "</tr>"
 	j = j + 1
next

Document.Write "<tr>"
Document.Write "<td nowrap colspan=""12""><input type=""hidden"" value=""" & j - 1 & """ name=""RC"">" & j - 1 & " Records</td>"
Document.Write "</tr>"
    </script>
<tr>
	<td nowrap colspan="12">Postoffice<input type="text" name="PO" size="30"><br>
    User Name<input type="text" name="UN" size="30"><br>
    Password<input type="text" name="PS" size="30"><bR>              
	</td>
</tr>
<tr>
	<td nowrap colspan="12"><input type="submit" value="Process" name="S"></td>
</tr>
</table>
</form>
</body>
</html>

Post Reply