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