+ Reply to Thread
Results 1 to 5 of 5

How to receive e-mail using Excel VBA

  1. #1
    Leonardo
    Guest

    How to receive e-mail using Excel VBA

    Hello. In this moment, I am writing a code, using the excellent
    information obtained from Ron de Bruin's site, about sending e-mail
    from excel.

    But my boss asks me to receive an e-mail to in order to modify VBA code
    execution, depending if there area some keywords inside the e-mail
    body, or FROM field. Where can I find info about receiving e-mail using
    Excel VBA ?

    Best regards.


  2. #2
    Tim Williams
    Guest

    Re: How to receive e-mail using Excel VBA

    Are you asking about scanning Outlook for received mails, or connecting to an account on a mailserver?

    Tim


    "Leonardo" <[email protected]> wrote in message news:[email protected]...
    > Hello. In this moment, I am writing a code, using the excellent
    > information obtained from Ron de Bruin's site, about sending e-mail
    > from excel.
    >
    > But my boss asks me to receive an e-mail to in order to modify VBA code
    > execution, depending if there area some keywords inside the e-mail
    > body, or FROM field. Where can I find info about receiving e-mail using
    > Excel VBA ?
    >
    > Best regards.
    >




  3. #3
    Leonardo
    Guest

    Re: How to receive e-mail using Excel VBA

    Hello. First choice is good to me: scanning Outlook to verifiy if a
    received e-mail contains some keywords in order to take some actions or
    not.


    LQ


  4. #4
    Tim Williams
    Guest

    Re: How to receive e-mail using Excel VBA

    Try this:

    '*************************************************************
    Sub CheckOutlookMessages2()

    Const S_SUBJECT As String = "YourSubjectHere"
    Dim olApp As Outlook.Application
    Dim fInbox As MAPIFolder

    Dim olInboxCollection As Object
    Dim olInboxItem As Object
    Dim iCount As Integer
    Dim itemCount, n

    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    If olApp Is Nothing Then
    MsgBox "Outlook is not running: please open the application first"
    Err.Clear
    Exit Sub
    End If
    On Error GoTo haveError

    'Get the inbox folder
    Set fInbox = olApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    Set olInboxCollection = fInbox.Items

    itemCount = olInboxCollection.Count
    iCount = 0
    For n = itemCount To 1 Step -1
    Set olInboxItem = olInboxCollection(n)
    If StrComp(olInboxItem.Subject, S_SUBJECT) = 0 Then

    iCount = iCount + 1
    Application.StatusBar = "Processing # " & iCount

    'here's where you get the info from the attachment....
    MsgBox olInboxItem.Body

    End If
    Next n

    haveError:
    If Err <> 0 Then MsgBox "Error:" & vbCrLf & Err.Description
    Application.StatusBar = False

    End Sub
    '***************************************************

    Tim

    "Leonardo" <[email protected]> wrote in message news:[email protected]...
    > Hello. First choice is good to me: scanning Outlook to verifiy if a
    > received e-mail contains some keywords in order to take some actions or
    > not.
    >
    >
    > LQ
    >




  5. #5
    Leonardo
    Guest

    Re: How to receive e-mail using Excel VBA

    Thank you, Tim. With your advise, I was able to write the code I
    needed.


    LQ


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1