Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi Guys, I have been asked if it

Status
Not open for further replies.

martenez

Technical User
Oct 9, 2003
11
GB
Hi Guys,

I have been asked if it is possible to have emails that arrive into the company to be imported straight into a table in Access XP eg online application forms in defined text format being read straight into a table as the emails arrive or when the database is first opened to run a process to import all emails that have been queueing.

Any help would be gratefully accepted PLLEAASSE

Pete
 
the simple answer is YES....BUT

assuming you use Outlook or similar you can write code to extract emails from the folders and manipulate any other exposed objects.

it's easy in theory but in practice it can become a nightmare. you will need to consider standardising folder names and structures, what do do with attachments, what to do with embedded graphics, etc. etc. If you use Outlook there are also various security issues introduced by 2000 SP3 that you need to understand.

without trying to be patronising it's not something that the enthusiastic amatuer should attempt (imho).

good luck
 
Here is some code i made.

The code checks the inbox for email with "afmeld" in the subject. If it finds one it will put the attachment in a folder.

Hope it will give you a start.
If you have a question please ask

Greetings
Ernst Jan


On Error Resume Next
Dim Word As Word.Application
Dim Klantcode, Medewerker, Servicebon, arbeid, werkzaamheden As String
Dim Outlook As Outlook.Application
Dim MyNameSpace As Object
Dim MyMail As Object
Dim MyItem As Object
Dim MyAttach As Object
Dim X, y As Integer
Dim naam As String
Dim Fs
Dim Filenaam As String
Dim Tabel As Object
Dim anderebon As Integer
Dim Folder As MAPIFolder

' open Outlook

Set Outlook = CreateObject("Outlook.application")
Set MyNameSpace = Outlook.GetNamespace("MAPI")
Set MyMail = MyNameSpace.GetDefaultFolder(olFolderInbox)
Set Fs = CreateObject("Scripting.FileSystemObject")

Set Tabel = CurrentDb.OpenRecordset("T-Afgemelde bonnen")


' set folder where email are put when they are processed

Set Folder = MyMail.Folders("Afgemeld")

' if the folder does not exist the it will be created

If Folder Is Nothing Then
Set Folder = MyMail.Folders.Add("Afgemeld")
Else
Set Folder = MyMail.Folders("Afgemeld")
End If

On Error GoTo Fout

For Each MyItem In MyMail.Items
If MyItem.subject Like "*afmeld*" Then
For Each MyAttach In MyItem.Attachments
For X = 1 To Len(MyAttach)
If Mid$(MyAttach, X, 1) = "_" Then
naam = Left$(MyAttach, X - 1)
End If
Next

' checking if the directory exists
' if not the directory is created

If Fs.folderexists("H:\" & naam) = False Then
Fs.createfolder ("H:\" & naam)
Fs.createfolder ("H:\" & naam & "\lan beheer")
Fs.createfolder ("H:\" & naam & "\lan beheer\werkrapporten")
End If

If Fs.folderexists("H:\" & naam & "\lan beheer") = False Then
Fs.createfolder ("H:\" & naam & "\lan beheer")
Fs.createfolder ("H:\" & naam & "\lan beheer\werkrapporten")
End If

If Fs.folderexists("H:\" & naam & "\lan beheer\werkrapporten") = False Then
Fs.createfolder ("H:\" & naam & "\lan beheer\werkrapporten")
End If

MyAttach.SaveAsFile ("H:\" & naam & "\lan beheer\werkrapporten\" & MyAttach)
Filenaam = "H:\" & naam & "\lan beheer\werkrapporten\" & MyAttach
GoSub Openen
Next

MyItem.Move MyMail.Folders("Afgemeld")
End If
Next

Tabel.Close
Set Outlook = Nothing

Form.Requery

sluiten:
Exit Sub

Fout:
MsgBox Err.Description
Resume sluiten
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top