Saving email from Outlook into Access (1 Viewer)

John liem

Registered User.
Local time
Today, 12:18
Joined
Jul 15, 2002
Messages
112
Hi, I try and need badly to save or attaching emails from Outlook, capturing at least the "From", "Sent Date", "Subject" and "Message Contents" fileds into a table in Access 2000.
Could you give me some suggestions or a way to do it using VBA? Thanks in advance. John :mad:
 

TomAllins

New member
Local time
Today, 12:18
Joined
Oct 7, 2004
Messages
7
As far as I know it is not possible to link emails to access.
However it is possible to store an email on a harddisk and save the location of the email in a field.

Remark: this code is written for outlook 2003 and access 2003. In order to work you need to include the 'Microsoft Outlook 11.0 Object library' in the references.

To add this reference, click in the vba-screen on Tools - References. Select 'Microsoft Outlook 11.0 Object library' to include the library.

I suppose you want to store one mail per record, so you would have a form with the textbox txtEmail and a commandbutton cmdAddmail

Private Sub cmdAddmail_Click()

txtEmail.value = Linkemail

end Sub

Below is the code which will send the full pathname and file to the textbox

Public Function LinkEmail()
'Description: determin the active mail, save it to server as msg-file
'and return the location to the caller

On Error GoTo Action_Err
'Variables
Dim myEmail As Inspector
Dim SaveEmail As Object
Dim strName As String
'Search for open mail
Set myEmail = Outlook.Application.ActiveInspector
If Not TypeName(myEmail) = "Nothing" Then
Set SaveEmail = myEmail.CurrentItem
SaveEmail.SaveAs "Enter path here (filename included) as string", olMSG
LinkEmail = strName
Else
MsgBox "No open mail has been detected" & Chr(13) & _
"If you wish to add an email, you will have " & Chr(13) & _
"to open the mail.", vbOKOnly, "No open mail detected"
End If


Action_Exit:
Exit Function

Action_Err:
'Error handling
MsgBox Err.description
GoTo Action_Exit
End Function

This function will copy the email as message to the place you defined, and create a string which will be stored in the the textbox.

Some practical issues with this method:
1/ the function will only work when the email-message is open.
2/ if you have opened multiple message, only the last opened message will be saved.
 

John liem

Registered User.
Local time
Today, 12:18
Joined
Jul 15, 2002
Messages
112
Thanks Tom,
The codes you have written, is it to be added in Access 2000 or Outlook?
I have tried to link the Outlook using link table methode, I can link my Outlook Inputbox to Access as a table, but on the contents of the message, I can only capture the first line.
Do you know if there is a way to capture all mesagge lines?
How can I open Outlook and read my Inbox from Access?
 

Friday

Registered User.
Local time
Today, 11:18
Joined
Apr 11, 2003
Messages
542
John:

Read this from Microsoft and see if it addresses your question (partially).
 

John liem

Registered User.
Local time
Today, 12:18
Joined
Jul 15, 2002
Messages
112
Hi Friday,

That is cool ... a lot of articles about Outlook, thanks!
J.
 

TomAllins

New member
Local time
Today, 12:18
Joined
Oct 7, 2004
Messages
7
John,

You need to include my code in Access.

What my code does, is storing the mail on a harddisk (outside the outlook mailbox) and store the location of the saved mail in access.

For my users I wrote an additional piece of code that enabled them to click on the location and outlook would automatically reopen the mail.

I don't know if you could store the message text in access, but check the link provided by Friday.
 
O

OPMCoordinator

Guest
Hello!

I just tried linking one of my folders in outlook as a table into access and can see all of the message contents just fine. Try stretching the size of the rows down when viewing the linked table in access the same way you stretch cells down in excell. Ive only just started playing this whole concept recently, but appears to have some awesome possibilities!

Cheers
Mike
 

John liem

Registered User.
Local time
Today, 12:18
Joined
Jul 15, 2002
Messages
112
Hi Mike,

Yes, I did realize a few days ago that I could strech the line down. Thanks anyway!
 

Users who are viewing this thread

Top Bottom