Results 1 to 4 of 4

Thread: How to log into Outlook account

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    How to log into Outlook account

    Is there any way in which we can log into our Outlook account throgh VB and send a mail.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to log into Outlook account

    Yes, add a reference to MS Outlook xx.0 Object Library and create an email. I have many many code examples on the forums already. Try a search by my user name and Outlook.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: How to log into Outlook account

    I know how to send a mail through VB but it works only if Outlook is open and any user is logged on. I want to know if we can supply the userID and password through code and execute it. I was using the following code to send the mail
    VB Code:
    1. Private Sub Form_Load()
    2. Dim app As Outlook.Application
    3. Dim mail As Outlook.MailItem
    4. Set app = CreateObject("Outlook.Application")
    5. Set mail = app.CreateItem(olMailItem)
    6.  
    7. With mail
    8.     .To = "[email protected]"
    9.     .Subject = "Hi This is a test mail"
    10.     .Body = "There is an error"
    11.     '.Attachments.Add "\\server\drive\folder\filename", olByValue, 1
    12.     .Send
    13. End With
    14. End Sub
    Can anyone help me out.
    Last edited by Hack; Jul 27th, 2006 at 10:47 AM. Reason: Fixed [vbcode] [/vbcode] tags

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to log into Outlook account

    You can log on like so...
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Dim app As Outlook.Application
    5.     Dim mail As Outlook.MailItem
    6.     Set app = CreateObject("Outlook.Application")
    7.     app.GetNamespace("MAPI").Logon "Profile", "Password", "ShowDialog", "New Session"
    8.     Set mail = app.CreateItem(olMailItem)
    9.     With mail
    10.         .To = "[email protected]"
    11.         .Subject = "Hi This is a test mail"
    12.         .Body = "There is an error"
    13.         '.Attachments.Add "\\server\drive\folder\filename", olByValue, 1
    14.         .Send
    15.     End With
    16. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width