
SIMIN
Avatar/Signature-
Posts
92 -
Joined
-
Last visited
About SIMIN
- Birthday 01/01/1980
SIMIN's Achievements
Newbie (1/14)
0
Reputation
-
Resolved Resolved :)
-
Thanks all, Yes, ContactID is a GUID, and it worked perfectly :)
-
Hi, Here is what I do to generate this ID: http://www.xtremedotnettalk.com/showthread.php?t=101780 Do you think I can use System.Guid.NewGuid.ToString() to generate these IDs? I never heard of System.Guid.NewGuid.ToString() until now.
-
Hi, I was sure I am writing the output file in the correct format, and I was right. However, I found the only problem is with my random generated IDs. It seems that I really cannot generate random alphanumeric IDs on the fly and use it in the .contact files. But how can I find how they generate these random IDs? :confused:
-
Hi everyone:) As you know, from Windows Vista, user contacts are not stored in .wab files anymore... However, they are stored here: X:\Users\Your User Name\Contacts I want to CREATE / GENERATE contacts programatically and save them here in the same format. This format is very simple and is user readable. For example, this sample: <?xml version="1.0" encoding="UTF-8"?> <c:contact c:Version="1" xmlns:c="http://schemas.microsoft.com/Contact" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:MSP2P="http://schemas.microsoft.com/Contact/Extended/MSP2P"> <c:CreationDate>2009-01-19T20:16:08Z</c:CreationDate><c:Extended xsi:nil="true"/> <c:ContactIDCollection><c:ContactID c:ElementID="7a122ea4-c7c5-4eb3-855e-39c97dc46a54"><c:Value>a18452d7-bc26-467d-8a5c-527d2c70ba8b</c:Value></c:ContactID></c:ContactIDCollection><c:EmailAddressCollection><c:EmailAddress c:ElementID="0e59a008-481c-4c99-b3cc-c85c89d616ff"><c:Type>SMTP</c:Type><c:Address>user@domain.com</c:Address><c:LabelCollection><c:Label>Preferred</c:Label></c:LabelCollection></c:EmailAddress><c:EmailAddress c:ElementID="280c131c-a5ad-41ca-acc2-aff9030c76a2" xsi:nil="true"/></c:EmailAddressCollection><c:NameCollection><c:Name c:ElementID="e8afd09a-9406-4e42-bad1-b4148ade040e"><c:FormattedName>user@domain.com</c:FormattedName></c:Name></c:NameCollection><c:PhotoCollection><c:Photo c:ElementID="834fd30a-de94-4558-b650-d3d8c3e1fcd9"><c:LabelCollection><c:Label>UserTile</c:Label></c:LabelCollection></c:Photo></c:PhotoCollection></c:contact> So, when I want to generate and save a contact here, I simply just change the email address and re-generate random IDs and save it as a .contact file in this location: Dim OutputString As String = Nothing OutputString = "<?xml version=""1.0"" encoding=""UTF-8""?>" + vbNewLine OutputString = OutputString + "<c:contact c:Version=""1"" xmlns:c=""http://schemas.microsoft.com/Contact"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:MSP2P=""http://schemas.microsoft.com/Contact/Extended/MSP2P"">" + vbNewLine OutputString = OutputString + vbTab + "<c:CreationDate>" + Now.ToString("yyyy-MM-dd") + "T" + Now.ToString("HH:mm:ss") + "Z</c:CreationDate><c:Extended xsi:nil=""true""/>" + vbNewLine OutputString = OutputString + vbTab + "<c:ContactIDCollection><c:ContactID c:ElementID=""" + GenerateContactID() + """><c:Value>" + GenerateContactID() + "</c:Value></c:ContactID></c:ContactIDCollection><c:EmailAddressCollection><c:EmailAddress c:ElementID=""" + GenerateContactID() + """><c:Type>SMTP</c:Type><c:Address>" + MyReaders("Email").ToString + "</c:Address><c:LabelCollection><c:Label>Preferred</c:Label></c:LabelCollection></c:EmailAddress><c:EmailAddress c:ElementID=""" + GenerateContactID() + """ xsi:nil=""true""/></c:EmailAddressCollection><c:NameCollection><c:Name c:ElementID=""" + GenerateContactID() + """><c:FormattedName>" + MyReaders("Email").ToString + "</c:FormattedName></c:Name></c:NameCollection><c:PhotoCollection><c:Photo c:ElementID=""" + GenerateContactID() + """><c:LabelCollection><c:Label>UserTile</c:Label></c:LabelCollection></c:Photo></c:PhotoCollection></c:contact>" + vbNewLine My.Computer.FileSystem.WriteAllText(WABPath + "\" + MyReaders("Email").ToString + ".contact", OutputString, False) However, although the final file contents will be exactly in the same format, but Windows will not recognize my created files as contacts!!! This is strange, I am sure they are in the same format!!! Anyone knows why this happens?! :confused: Thank you...
-
Hi, I wanna generate a random alphanumeric in the following format: d4g2o5m3-u1q2-s7z9-z6o8-o3q2c2m5m2s9 So with your help, I wrote a public function like this: Public Function GenerateContactID() As String Dim MyRandom As New Random GenerateContactID = Nothing For MyLoop As Integer = 1 To 8 If MyLoop Mod 2 = 1 Then GenerateContactID = GenerateContactID + Convert.ToChar(MyRandom.Next(97, 123)) End If If MyLoop Mod 2 = 0 Then GenerateContactID = GenerateContactID + MyRandom.Next(1, 10).ToString End If Next GenerateContactID = GenerateContactID + "-" For MyLoop As Integer = 1 To 4 If MyLoop Mod 2 = 1 Then GenerateContactID = GenerateContactID + Convert.ToChar(MyRandom.Next(97, 123)) End If If MyLoop Mod 2 = 0 Then GenerateContactID = GenerateContactID + MyRandom.Next(1, 10).ToString End If Next GenerateContactID = GenerateContactID + "-" For MyLoop As Integer = 1 To 4 If MyLoop Mod 2 = 1 Then GenerateContactID = GenerateContactID + Convert.ToChar(MyRandom.Next(97, 123)) End If If MyLoop Mod 2 = 0 Then GenerateContactID = GenerateContactID + MyRandom.Next(1, 10).ToString End If Next GenerateContactID = GenerateContactID + "-" For MyLoop As Integer = 1 To 4 If MyLoop Mod 2 = 1 Then GenerateContactID = GenerateContactID + Convert.ToChar(MyRandom.Next(97, 123)) End If If MyLoop Mod 2 = 0 Then GenerateContactID = GenerateContactID + MyRandom.Next(1, 10).ToString End If Next GenerateContactID = GenerateContactID + "-" For MyLoop As Integer = 1 To 12 If MyLoop Mod 2 = 1 Then GenerateContactID = GenerateContactID + Convert.ToChar(MyRandom.Next(97, 123)) End If If MyLoop Mod 2 = 0 Then GenerateContactID = GenerateContactID + MyRandom.Next(1, 10).ToString End If Next End Function However, sometimes the call to this function will return the same result, I mean it's not completely random? How that's possible? Thank you :)
-
Private ReportLog As StringBuilder Private Sub DoThat() 'We didn't assign any value to the ReportLog so here we want to check if it's empty or not? If ReportLog IsNot Nothing And ReportLog.Length > 0 Then ' End IF End Sub The problem is that "If ReportLog IsNot Nothing And ReportLog.Length > 0 Then" itself throws an exception! A first chance exception of type 'System.NullReferenceException' occurred in MyApp.exe A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll How should I check that variable? Thank you :)
-
The build number of Vista SP1 is the same as Windows Server 2008 and that makes the problem!
-
How do you people get this special folder? D:\Users\My User Name\ I tried to get all special folders but was not able to get this one in Vista! :( IS that possible or I cannot find it? Thanks.
-
Hi everyone, How can I detect if my current OS which my program is running under, is Windows Vista? Please note that there are 2 versions of Vista: Vista and Vista SP1. The build number of Vista SP1 is the same as Windows Server 2008 and that makes the problem! I just want to make sure my OS is vista?! Please help me :) Thanks all...
-
Hi and thanks :) you are so kind I just replaced it in my code and it's working, I think so :) sorry but for final confirm we can say that these 2 codes are the same now? code1: Private Function StripNullChars(ByVal MyString As String) As String Do While Len(MyString) > 0 If Asc(VB.Right(MyString, 1)) <> 0 Then Exit Do MyString = VB.Left(MyString, Len(MyString) - 1) Loop StripNullChars = MyString End Function code2: Private Function StripNullChars(ByVal MyString As String) As String StripNullChars = MyString.Trim(Convert.ToChar(0)) End Function
-
hi thanks and many thanks for all your valuable helps :) I am a little bit confused so my final converted code would be: Private Function StripNullChars(ByVal MyString As String) As String StripNullChars = MyString.Trim(vbNull) End Function you mean? but it has error thanks again :)
-
Hi, I want to convert this VB6 code to VB.NET: Private Function StripNullChars(ByVal MyString As String) As String Do While Len(MyString) > 0 If Asc(VB.Right(MyString, 1)) <> 0 Then Exit Do MyString = VB.Left(MyString, Len(MyString) - 1) Loop StripNullChars = MyString End Function However, I don't know what are replacements .NET version of VB.Left and VB.Right? Please help me. Thanks.
-
Hi eveyone. I would like to read a binary file: Windows Address Book. However, since I JUST want to import email addresses from WAB to my application I think I can open and read it myself. If you see my snapshot, email addresses are human readable and just with spaces, not encoded! So I think this command will open file file well: Dim ReadText As Byte() = System.IO.File.ReadAllBytes("C:\Documents and Settings\Username\Application Data\Microsoft\Address Book\Username.wab") The only problem is that I never tried to read binary files. And don't know how to process this Byte variable: ReadText! Do you have any idea how can I just extract email addresses? I even have regex code to do it, but don't know how to process ReadText? Please help me :(
-
Hi everyone, Happy New Year! :D I have a question, anyone tried to read Windows Address Book (WAB) file via his VB program? In XP, it is usually located in: C:\Documents and Settings\Username\Application Data\Microsoft\Address Book It is named "Username.wab" and I want to read it and import its contacts to my own contact manager program! Please help me if you can :)