Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    ck4794 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Oct 2013
    Posts
    80

    Quote Originally Posted by June7 View Post
    I tested rpeare's db and the code runs without error. Info is output to immediate window. Using Access 2010.

    thanks. i am also using 2010. i was having the same issues on my home computer running 2013

  2. #17
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    what does the TO field say on the email you're processing, the only thing I can think is that there's some character in there that the code doesn't like.

    I don't understand why you would get the subject but bomb on the .to

    maybe try it without the WITH statement

    Code:
    Dim olNS As NameSpace
    Dim item As Object
    Dim Inbox As MAPIFolder
    Dim SubInbox As MAPIFolder
    
    Set olNS = GetNamespace("MAPI")
    Set Inbox = olNS.GetDefaultFolder(olFolderInbox)
    Set SubInbox = Inbox.Folders("TEST")
    Dim sSQL As String
    
    For Each item In SubInbox.Items
        If TypeOf item Is MailItem Then
            'With item
                Debug.Print item.subject
                Debug.Print item.to
                Debug.Print item.body
                Debug.Print item.SenderEmailAddress
                'if you get values in these debug.print statements you can move on to the SQL which in your example won't work
                'DoCmd.RunSQL "INSERT INTO TEST(subject, to) SELECT '" & & "','" & .To & "'"
            'End With
        End If
    Next item
    Set ns = Nothing
    Set olNS = Nothing
    Set Inbox = Nothing
    Set SubInbox = Nothing
    Also, try switching the order of the debug.print statements, see if there are any others that are causing problems.
    Also, try moving the debug.print .to or debug.print item.to to the first debug.print statement and see if maybe there's a problem after the first item is printed

  3. #18
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    just another thought, try removing the email that the code is choking on from the folder you're checking and see if it can get through a different email.

  4. #19
    ck4794 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Oct 2013
    Posts
    80
    So I found out that the problem is a security issue being on a DOD computer, and DOD email.

  5. #20
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    well we can't help you with that!

  6. #21
    ck4794 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Oct 2013
    Posts
    80
    Quote Originally Posted by rpeare View Post
    well we can't help you with that!
    yea i know... oh well. thanks anyways.

    i think there might be an answer here :
    http://www.outlookcode.com/article.aspx?ID=52
    in the "run a script" section. but i can't quite figure out what i need to do.

  7. #22
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can try the CDO method rather than the MAPI method, but I don't know that you'll have much success. The page you linked is really just telling you how to get around the annoying message that pops up when you try to send an email using the MAPI method, not when you just try to read the information in an email.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

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