Results 1 to 5 of 5
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185

    Emails in list box

    Hi Guy's, is it possible to auto check email inbox and add recipient / subject / body to a table ?



    Then i can create a list box then on click, reply with default replies based on a DLookup and item, i guess i am trying to refresh inbox then click to to reply and send, this bit i can do without a problem, it would be how to retrieve emails in a list box
    I have tried the following,
    External Data
    New Data Source
    From Other Sources
    Outlook Folder
    used the import source data into a new table in the current database
    Clicked the relevant inbox
    this creates a table called inbox

    is there a method I can do this import without using the wizard and do it on 30 minute timer ?

    Thanks in advance

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    add the code below to OUTLOOK vbe module.
    this will take the current email being viewed,and add the info to your Db.

    you MUST add the ADO connection in VBE references: menu, tools, references
    checkmark: Microsoft ActiveX Data Objects X.X Library

    user can click a button on Quick toolbar to run GrabCurrEdata()

    Code:
    Public Sub GrabCurrEdata()
    Dim oInspector As Inspector
    Dim oItem As MailItem
    Dim vSubj, vFrom, vTo, vBody, vName
        
    Set oInspector = Application.ActiveInspector
    If oInspector Is Nothing Then
        MsgBox "No active inspector"
    Else
        Set oItem = oInspector.CurrentItem
        vName = oItem.Sender
        vFrom = oItem.SenderEmailAddress
        vSubj = oItem.Subject
        vBody = oItem.Body
        'vTo = oItem.Recipients(1)
       
           'send info to db
       Add1Rec vName, vFrom, vSubj, vBody
    End If
        
    Set oItem = Nothing
    Set oInspector = Nothing
    End Sub
    
    
    Private Sub Add1Rec(pvName, pvEmail, pvSubj, pvBody)
    Dim conn As ADODB.Connection
    Dim cmd As New ADODB.Command
    Dim sSql As String
    Const kDB = "c:\folder\northwind.mdb"
    
    on error goto errAdd
       'NOTE: you must add the ADO reference in VBE menu: tools, references
       'mark: Microsoft ActiveX Data Objects X.X Library
       
    Set conn = CreateObject("ADODB.Connection")
    conn.Provider = "Microsoft.Jet.OLEDB.4.0"
    conn.Open kDB
    
    sSql = "insert into table (Name, Email, Subj, Body) values ('" & pvName & "','" & pvEmail & "','" & pvSubj & "','" & pvBody & "');"
    With cmd
         .CommandText = sSql                
         .CommandType = adCmdText
         .ActiveConnection = conn.ConnectionString
         .Execute
     End With
    Endit:
    conn.Close
    Set rst = Nothing
    Set conn = Nothing
    Exit Sub
    errAdd:
    MsgBox Err.Description
    Resume Endit
    End Sub

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi ranman256, thank you very much for this, i have completed all of your suggestion, where is the GrabCurrEdata() ? how do i find quick toolbar as suggestion ?

    do i need a command button on db form called GrabCurreData ?

    Thanks again

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    I did what you suggested, i don't have
    Microsoft ActiveX Data Objects X.X Library listed in the references, the closest there is Microsoft Active X Object Library

    Kind Regards

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi Guy's, i have tried to have a db to recieve emails, ideally on timer, when i import, each time the table (inbox) field names are different ?

    Also trying to use the method below but i don't have Microsoft Active Data Objects X.X Library

    The closest I have listed in the references is Microsoft ActiveX Data Objects 6.1

    Any ideas ?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 12-13-2017, 10:38 AM
  2. Replies: 6
    Last Post: 01-26-2017, 06:15 AM
  3. List of emails based on name selections.
    By Coxck in forum Access
    Replies: 1
    Last Post: 01-07-2016, 03:29 PM
  4. Emails with a Macro
    By srcacuser in forum Access
    Replies: 5
    Last Post: 05-02-2012, 11:49 AM
  5. Automatic Emails
    By smit2215 in forum Queries
    Replies: 1
    Last Post: 03-10-2011, 01:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums