Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   Getting Alias from Address Book ??? (http://www.programmingforums.org/showthread.php?t=13410)

paulchwd Jun 22nd, 2007 9:55 AM

Getting Alias from Address Book ???
 
Hello All,

I have a small app that sends an email to a person and then looks up their manager in Address Book and sends them an email..unfortunetly there are duplicate names in address book and emails are the same, thus I need to use Alias (or so i've been told)...i cant seem to access the alias field though..

My Code:

:

Private Sub doEmail(ByVal Qrecords() As String, ByVal Nrecords() As String, ByVal recordSize As Integer)

        Dim i As Integer 'loop counter
        Dim OutlookApp As New Microsoft.Office.Interop.Outlook.Application 'application
        Dim msg As Microsoft.Office.Interop.Outlook._MailItem 'Mail item 

        Dim attached As Microsoft.Office.Interop.Outlook.Attachments '= msg.Attachments
        Dim attached2 As Microsoft.Office.Interop.Outlook.Attachment

        Dim oNameSpace As Microsoft.Office.Interop.Outlook.NameSpace
        oNameSpace = OutlookApp.GetNamespace("MAPI")

        Dim oAddressLists As Microsoft.Office.Interop.Outlook.AddressLists
        Dim oAddressList As Microsoft.Office.Interop.Outlook.AddressList
        oAddressLists = oNameSpace.AddressLists
        oAddressList = oAddressLists.Item("All Users")

        For i = 0 To UBound(Nrecords)
            msg = OutlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
            attached = msg.Attachments
            msg.To = Nrecords(i)

            If managers.Checked Then
                If Not oAddressList.AddressEntries.Item(Nrecords(i)).Manager Is Nothing Then
                    msg.CC = oAddressList.AddressEntries.Item(Nrecords(i)).Manager.ID

                End If
            End If


            msg.Subject = "Pls review within within 30 days"

            msg.Body = "Your ID: " & Qrecords(i) & " currently has access to." & systemName.Text & Environment.NewLine & Environment.NewLine & " If you still require this access, please respond to " & replyToTxt.Text & " by: " & replyDate.Text & " with the document attached." & vbCrLf & " Please note, if we do not receive a reply by " & replyDate.Text & ", access will be disabled." & vbCrLf & vbCrLf & " Thank you " & vbCrLf & " Please not this is an automated message, please do not reply to sender."
            If Len(attachedFile) > 0 Then
                attached2 = attached.Add(attachedFile)
            End If

            msg.Send()

        Next
    End Sub


Any Thoughts ... Many thanks in advance

bigguy Jun 23rd, 2007 4:38 AM

How can emails be the same?
There cant be two same emails addresses. Like one might be person_123@yahoo.com, but there cant be another person_123@yahoo.com, you see what I'm saying. It could be person_123@gmail.com. Not sure what you mean by same email addresses.

And for the duplicate names in address book.Why not add their last names or something. Like James Henry or J. Henry or James H. Something like that?

john Wesley Jun 23rd, 2007 1:34 PM

Choosing to ignore bigguys post, I recommend you search the Global Address List for alias's because the Alias property is not held within a contacts details but in its properties so you wont find it in the Address Book.


All times are GMT -5. The time now is 11:22 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC