I am using the code below to import information from one selected email in Outlook into Access. The code works.
The code allows me to highlight an email in Outlook then using a command button in Access the email infomation is pulled into Access. The code does not retrieve attachment information.
What I need help with is modifying the code to also retrieve any attachment file names into a text box on the form like the other email information.
Any help would be appreciated.
Thank you
The code allows me to highlight an email in Outlook then using a command button in Access the email infomation is pulled into Access. The code does not retrieve attachment information.
What I need help with is modifying the code to also retrieve any attachment file names into a text box on the form like the other email information.
Any help would be appreciated.
Thank you
Code:
Dim objApp As Outlook.Application
Dim objItem As Outlook.MailItem
Dim SndName As String, SndAddr As String, ToName As String, CCName As String
Dim Subj As String, Rcvd As String, MsgBody As String, AtchName As String
Dim Atch As Outlook.Attachment
Set objApp = New Outlook.Application
For Each objItem In objApp.ActiveExplorer.Selection
If objItem.Class = olMail Then
With objItem
SndName = .SenderName
SndAddr = .SenderEmailAddress
ToName = .To
CCName = .CC
Subj = .Subject
MsgBody = .Body
Rcvd = .ReceivedTime
End With
End If
Next
Me.txtMsgBody = MsgBody
Me.txtSndName = SndName
Me.txtSndAddr = SndAddr
Me.txtTONAME = ToName
Me.txtCCName = CCName
Me.txtSubj = Subj
Me.txtRcvd = Rcvd
Set objItem = Nothing
Set objApp = Nothing