Good morning Veena,
Your directives is getting me closer to my objective. I did as you said. Now, I am stepping thru the program and I can see the email address information being loaded into the flexgrid control. However at a point, I want to be able to select an email address from the flexgrid, place it in the "EmailID" variable which I will subsequently point to in the "OutlookMailItem.To = EmailID"
See all my code/setup below:
Private Sub Flxgrd_Click()
Dim OutlookApp As Outlook.Application
Dim OutlookNameSpace As Outlook.NameSpace
Dim OutlookAddressList As Outlook.AddressList
Dim OutlookAddressEntry As Outlook.AddressEntry
Dim OutlookMailItem As Outlook.MailItem
Dim i As Long
Dim EmailID As String
Dim OutlookAttachment As Outlook.Attachment
Dim MailAttach As String
MailAttach = "C:\ProjectStatus.xls"
Flxgrd.Rows = 1
Flxgrd.Cols = 4
i = 0
Set OutlookApp = New Outlook.Application
Set OutlookNameSpace = OutlookApp.GetNamespace("MAPI")
For Each OutlookAddressList In OutlookNameSpace.AddressLists
For Each OutlookAddressEntry In OutlookAddressList.AddressEntries
i = i + 1
Flxgrd.Rows = i + 1
Flxgrd.TextMatrix(i, 0) = OutlookAddressEntry.Name
Flxgrd.TextMatrix(i, 1) = OutlookAddressEntry.Address
Flxgrd.TextMatrix(i, 2) = OutlookAddressEntry.ID
Flxgrd.TextMatrix(i, 3) = OutlookAddressEntry.ID
Next
Next
EmailID = "gift.xtian@nyct.com"
SENDEMAIL:
OutlookMailItem.To = EmailID
OutlookMailItem.Subject = "Project Status"
OutlookMailItem.Body = "This is VB email test"
If Not IsMissing(MailAttach) Then
Set OutlookAttachment = OutlookMailItem.Attachments.Add(MailAttach)
End If
'If Len(MailAttach) > 0 Then
' OutlookMailItem.Attachments.Add "C:\ProjectStatus.xls", olByValue, 1, "ProjectStatus"
'End If
'OutlookMailItem.Display 'To display the email
OutlookMailItem.Send 'To send the email
Set OutlookApp = Nothing
Set OutlookMailItem = Nothing
Set OutlookNameSpace = Nothing
Set OutlookAddressList = Nothing
Set OutlookAddressEntry = Nothing
Set OutlookAttachment = Nothing
End Sub