How to get header info/email address from Outlook into Access

  • Thread starter Pamela via AccessMonster.com
  • Start date
P

Pamela via AccessMonster.com

Hello;

I have added a section to my database application which allows users to
attach highlighted emails in Outlook. All works great except that I was
wondering how to extract the sender's email address or header information
from Outlook? I can get the sender's name, but would like to be able to
include their actual email address as well. Here is the code:

For Each itm In sel
If itm.Class = olMail Then
Set msg = itm

rstMail.AddNew
DoCmd.Hourglass True
'MsgBox ("record = ") & Forms!frmCorrespondence.ID
rstMail![CorrespID] = Forms!frmCorrespondence.ID
rstMail![From] = msg.SenderName
rstMail![Subject] = msg.Subject
rstMail![CC] = msg.CC
rstMail![BCC] = msg.BCC
rstMail![Sent] = msg.CreationTime
rstMail![Body] = msg.Body
lngMessageID = rstMail![MessageID]
rstMail.Update 'update Mail Messages Table
'''''''''''''''''''''''''''''''''''''''''''''''''''

'Work with mail message's Attachments collection
If msg.Attachments.Count > 0 Then
For Each att In msg.Attachments
rstAtts.AddNew 'add new record
strAttFile = strAttsPath & att.FileName
Msg2 = "Save File " & att.FileName & " To:" & strAttFile & "?"
Response = MsgBox(Msg2, vbYesNo, "Save Attachment?")
If Response = vbNo Then GoTo Continue 'do not save attachment

'Process attachments
att.SaveAsFile strAttFile
strHyperlink = Chr$(35) & strAttFile & Chr$(35)
rstAtts![MessageID] = lngMessageID
rstAtts![Attachment] = strHyperlink
rstAtts.Update
Continue: Next att 'process next attachment
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
Next itm
 
R

Ron2005

I believe you will find it in the "From" field.

If it is a name that is in Outlook's address book then it will contain
that name and not a regular formated email address. If it is not in the
address book then it will have a different format - I do not happen to
have any in my file that came from someone that is not in my address
book.

It may take some fooling around to force it to give you the standard
form.

Ron
 
P

Pamela via AccessMonster.com

OK. Thanks. I was trying to get it to display the actual email address
instead of the name, but I have noticed that it will fill in the From field
with what it literaaly says in "From". I was wanting to be able to respond
the the sender of the saved email directly from the form. It does, but if it
fills in the "To" field with [txtFrom] with a name Outlook's contacts doesn't
recognize, unless the sender's email address is in the body of the saved
email itself, you may not know the sender's email address.

The reason they are wanting to do this is because the inboxes for email
requests are constantly running out of space, so they wanted me to figure out
a way to store these emails someplace else. These emails are also attached
to or related to records in an Access Database (Request Tracking DB), so I am
storing the messages & attachments in the Access DB, & it's working great,
except for this small piece.

Maybe there's a way to configure Outlook to show the actual email address of
the sender for incoming emails? I'll keep playing with it. :)

Thanks!
 
R

Ron2005

Frustrating.

We know it is really in there, because if you open the email and right
click - properties for someone who is not in the address book, it will
display the real address.

Now how to get to it is something else.....

Ron
 
Top