PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VB6.0 - Office Outlook mail retrieval-VBForums
Results 1 to 12 of 12

Thread: VB6.0 - Office Outlook mail retrieval

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    VB6.0 - Office Outlook mail retrieval

    Hi,

    This is a Visual Basic 6.0 example I created back in 2005. This example shows you how to use the mapi components in VB to take advantage of Office Outlook (2003)'s email abilities. The MSMapi32.ocx is required in order for the code to work properly.

    Code:

    frmAttachments
    vb Code:
    1. 'Copyright 2005 "nightwalker83"
    2. Private Sub cmdAttach_Click()
    3. CDFiles.ShowOpen
    4. txtFile.Text = CDFiles.FileName
    5. LstFiles.AddItem CDFiles.FileName
    6. lblCount.Caption = lblCount.Caption + 1
    7. End Sub
    8.  
    9. Private Sub cmdCancel_Click()
    10. Unload Me
    11. End Sub
    12.  
    13. Private Sub cmdDelete_Click()
    14. For r = 0 To LstFiles.ListCount - 1
    15. LstFiles.RemoveItem (0)
    16. lblCount.Caption = lblCount.Caption - 1
    17. Next r
    18. txtFile.Text = ""
    19. End Sub
    20.  
    21. Private Sub cmdDone_Click()
    22. Me.Hide
    23. End Sub
    24.  
    25. Private Sub Form_Load()
    26. txtFile.Locked = True
    27. End Sub

    frmCompose
    vb Code:
    1. Private Sub cmdAttach_Click()
    2. 'Show attachments.
    3. frmAttachments.Show vbModal, Me
    4. End Sub
    5.  
    6. Private Sub cmdClear_Click()
    7. 'Clear all fields.
    8. txtTO.Text = ""
    9. txtSubject.Text = ""
    10. txtBody.Text = ""
    11. End Sub
    12.  
    13. Private Sub cmdClose_Click()
    14. 'Unload the form.
    15. Unload Me
    16. End Sub
    17.  
    18. Private Sub cmdSend_Click()
    19. 'Check whether or not to save then send the message.
    20.  frmMain.MAPIMessages1.MsgIndex = -1
    21. frmMain.MAPIMessages1.RecipAddress = txtTO.Text
    22. 'Double checks that address is valid.
    23. frmMain.MAPIMessages1.ResolveName
    24. frmMain.MAPIMessages1.MsgSubject = txtSubject.Text
    25. frmMain.MAPIMessages1.MsgNoteText = txtBody.Text
    26. 'Check for attachments.
    27. If frmAttachments.LstFiles.ListCount <> 0 Then
    28.  For a = 0 To frmAttachments.LstFiles.ListCount - 1
    29.  For S = 1 To (frmAttachments.LstFiles.ListCount)
    30.  sp = Split(frmAttachments.LstFiles.List(a), "\")
    31.  frmMain.MAPIMessages1.AttachmentName = sp(S)
    32.  Next S
    33.  frmMain.MAPIMessages1.AttachmentIndex = (a)
    34.   frmMain.MAPIMessages1.AttachmentPosition = (a)
    35. frmMain.MAPIMessages1.AttachmentPathName = frmAttachments.LstFiles.List(a)
    36. Next a
    37. End If
    38. 'Save the message.
    39. If chkSave.Value = 1 Then
    40. frmMain.MAPIMessages1.Save
    41. End If
    42. 'Send the message.
    43. frmMain.MAPIMessages1.Send (False)
    44. End Sub

    frmMain
    vb Code:
    1. Private Sub Form_Load()
    2. Dim itmM As ListItem, MCount As Variant, MsgCount As Variant, COLH As Integer
    3.  
    4. 'Logon to your Email account.
    5. MAPISession1.LogonUI = True
    6. 'Sign in to your email account.
    7. MAPISession1.SignOn
    8. 'Make sure the messages are used in the current session.
    9. MAPIMessages1.SessionID = MAPISession1.SessionID
    10. 'Download new mail from inbox.
    11. MAPISession1.DownLoadMail = False
    12. MAPIMessages1.FetchUnreadOnly = True
    13. MAPIMessages1.Fetch
    14. 'Sort the messages.
    15. MAPIMessages1.FetchSorted = True
    16. 'Check how many messages were received.
    17. MCount = MAPIMessages1.MsgCount
    18. 'Show received messages.
    19. For MsgCount = 0 To MCount - 1
    20. Next MsgCount
    21. 'Adjusts the index of each column so it can display the correct information.
    22. For COLH = 0 To 2
    23. Set itmM = LstNewMail.ListItems.Add(, , MAPIMessages1.MsgOrigAddress)
    24. COLH = COLH + 1
    25. itmM.SubItems(COLH) = MAPIMessages1.MsgSubject
    26. COLH = COLH + 1
    27. itmM.SubItems(COLH) = MAPIMessages1.MsgDateReceived
    28. Next COLH
    29. frmMain.Caption = frmMain.Caption & " " & "You have " & MsgCount & " new messages!"
    30. frmMain.Show
    31. End Sub
    32.  
    33. Private Sub Form_Unload(Cancel As Integer)
    34. 'Sign out of your email account.
    35. MAPISession1.SignOff
    36. End Sub
    37.  
    38. Private Sub mnuAddress_Click()
    39. 'Opens the address book.
    40. On Error Resume Next
    41. MAPIMessages1.Show
    42. End Sub
    43.  
    44. Private Sub mnuCompose_Click()
    45. 'Compose a new email message.
    46. frmCompose.Show vbModal, Me
    47. End Sub
    48.  
    49. Private Sub mnuExit_Click()
    50. 'Exit the application.
    51. Unload Me
    52. End
    53. End Sub
    54.  
    55. Private Sub mnuReadMessages_Click()
    56. 'Opens the form so you can read any new emails.
    57. frmRead.Show vbModal, Me
    58. End Sub

    frmRead
    vb Code:
    1. Private Sub cmdClose_Click()
    2. 'Unload the form.
    3. Unload Me
    4. End Sub
    5.  
    6. Private Sub cmdDelete_Click()
    7. 'Deletes current message.
    8. frmMain.MAPIMessages1.Delete
    9. txtBody.Text = ""
    10. txtSubject.Text = ""
    11. txtFrom.Text = ""
    12. frmMain.Refresh
    13. End Sub
    14.  
    15. Private Sub Form_Load()
    16. 'Locked the text disable the textboxes so they are read only.
    17. txtFrom.Enabled = False
    18. txtSubject.Enabled = False
    19. txtBody.Locked = True
    20. 'Get information from the message so it can be read.
    21. txtFrom.Text = frmMain.MAPIMessages1.MsgOrigAddress
    22. txtSubject.Text = frmMain.MAPIMessages1.MsgSubject
    23. txtBody.Text = frmMain.MAPIMessages1.MsgNoteText
    24. 'If there are no more messages disable the delete button.
    25.  If frmMain.MAPIMessages1.MsgCount = "0" Then
    26.   cmdDelete.Enabled = False
    27. End If
    28. End Sub

    Module1
    vb Code:
    1. Public a As Integer
    2. Public Path As String

    Nightwalker
    Attached Files Attached Files
    Last edited by Nightwalker83; Jun 19th, 2012 at 02:19 AM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  2. #2

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: VB6.0 - Office Outlook mail retrieval

    In-order to bypass the security restrictions in office outlook/outlook express you can either try and use a work around such as Redemption or you can uninstall office outlook/outlook express whichever you use and install Windows Live Mail. Windows Live Mail does not have the same security patch applied to it as office outlook/outlook express does so the above code will work without any issues.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: VB6.0 - Office Outlook mail retrieval

    11/07/2010 - See first post for updated attachment! Rewrote the code so that it uses redemption instead of simple mapi. Download redemption from the above url and reference it in the project in-order to use the code.
    Last edited by Nightwalker83; Jul 11th, 2010 at 05:43 PM. Reason: Fixed spelling
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: VB6.0 - Office Outlook mail retrieval

    1. you called the sendmail sentmail, so it's a bug, but this is a small thing.

    2. i get an error 429: "ActiveX component can't create object"

  5. #5

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: VB6.0 - Office Outlook mail retrieval

    2. i get an error 429: "ActiveX component can't create object"
    You need to download the "Developer" version of Redemption from the above site and install it. Once it is installed reference it in the project.

    Edit:

    I fixed the send mail problem.

    Also, the code does not work without outlook installed! I have suggested this could be changed in the next version of Redemption if say Windows Live Mail is only installed. My original code worked regardless of whether or not outlook was installed on the system.
    Last edited by Nightwalker83; Jul 11th, 2010 at 08:51 PM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  6. #6
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: VB6.0 - Office Outlook mail retrieval

    aha
    i don't have outlook

    1. i already downloaded the developer version, and extracted only the dll without using install.
    and the references worked ok, but i got this error, i think because i miss some mapi component
    that comes with outlook.

    i read in the redemption site that if i don't have outlook i need to download something from microsoft,
    i'll check this when i'll have time.

  7. #7

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: VB6.0 - Office Outlook mail retrieval

    Quote Originally Posted by whatsup View Post
    aha
    i don't have outlook

    1. i already downloaded the developer version, and extracted only the dll without using install.
    and the references worked ok, but i got this error, i think because i miss some mapi component
    that comes with outlook.

    i read in the redemption site that if i don't have outlook i need to download something from microsoft,
    i'll check this when i'll have time.
    I'm in the same boat! On my Laptop I only have Windows Live Mail installed.
    On the redemption home page it says:

    If you are planning to use the RDO family of objects on a Windows server that does not have Outlook, Exchange Server or Exchange Admin installed, you will need to install the standalone version of MAPI from the Microsoft site.
    There is a download link for the standalone version of MAPI next to the text. The file is ExchangeMapiCdo.

    Edit:

    I think I have to rewrite the program to use ExchangeMapiCdo because I installed it on my laptop and my program still failed. Although, maybe that was because ExchangeMapiCdo wasn't referenced in the project.
    Last edited by Nightwalker83; Jul 12th, 2010 at 07:39 PM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  8. #8

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: VB6.0 - Office Outlook mail retrieval

    I have found some third party components that I can use to send and receive email without outlook. I will start a new thread in the codebank when I have converted all the functions to work without outlook. We Only Do are the components I'm using.

    Edit:

    The updated version of the code can be found here.
    Last edited by Nightwalker83; Aug 8th, 2010 at 01:34 AM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  9. #9
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: VB6.0 - Office Outlook mail retrieval

    Public RDOSession As Redemption.RDOSession


    what am i missing what is the refference for this

  10. #10

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: VB6.0 - Office Outlook mail retrieval

    Quote Originally Posted by ladoo View Post
    Public RDOSession As Redemption.RDOSession


    what am i missing what is the refference for this
    You need to install and reference Redemption in your project! See post #2.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  11. #11
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Re: VB6.0 - Office Outlook mail retrieval

    Is this working with SSL authentication like gmail?

  12. #12

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: VB6.0 - Office Outlook mail retrieval

    Quote Originally Posted by green.pitch View Post
    Is this working with SSL authentication like gmail?
    See my reply in post #18 here.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width