login about faq

Can't get this to work in VB6 and can't find working VB6 code example.

Want to loop check gmail to notify me if any new emails arrive.


asked Jul 17 '13 at 13:14

wizzy411's gravatar image


I just tried the following code and it works for me with 9.4.0 (haven't tried 9.4.1 yet):

Option Explicit

Private Sub Command1_Click()
    Dim lo_Imap As CHILKATIMAPLib.ChilkatImap
    Dim lo_MsgSet As CHILKATIMAPLib.messageSet

    Set lo_Imap = New CHILKATIMAPLib.ChilkatImap

    ' Use your unlock code to unlock the component
    If lo_Imap.UnlockComponent("YOUR UNLOCK CODE") <> 1 Then
        Err.Raise vbObjectError, , "Could not unlock IMAP component." & vbNewLine & lo_Imap.LastErrorText
    End If

    With lo_Imap
        ' Setup connection settings (Example uses Gmail IMAP connection settings)
        .Port = 993
        .Ssl = 1

        ' Connect to the server (example uses GMail IMAP server)
        If .Connect("imap.gmail.com") <> 1 Then
           Err.Raise vbObjectError, , "Could not connect to IMAP server." & vbNewLine & .LastErrorText
        End If

        ' Use your e-mail username and password to login
        If .Login("myemail@gmail.com", "mypassword") <> 1 Then
            Err.Raise vbObjectError, , "Could not login to IMAP server." & vbNewLine & .LastErrorText
        End If

        ' Select the Inbox
        If .SelectMailbox("inbox") <> 1 Then
            Err.Raise vbObjectError, , "Could not select Inbox." & vbNewLine & .LastErrorText
        End If

        ' Get unread messages
        Set lo_MsgSet = .Search("UNSEEN", 1)
        If lo_MsgSet Is Nothing Then
            Err.Raise vbObjectError, , "Could not retrieve new messages." & vbNewLine & .LastErrorText
        End If

        ' Display the retrieved message count
        MsgBox "Found new message count: " & lo_MsgSet.Count
    End With
End Sub

answered Jul 17 '13 at 20:24

jpbro's gravatar image

jpbro ♦

Hmm, that worked with DLL but didn't work as ocx. Odd so switched coding to use dll rather than ocx



answered Jul 18 '13 at 00:47

wizzy411's gravatar image


There's a Chilkat IMAP OCX?

(Jul 18 '13 at 08:53) jpbro ♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jul 17 '13 at 13:14

Seen: 2,218 times

Last updated: Jul 18 '13 at 08:53

powered by OSQA