Page 1 of 2 12 LastLast
Results 1 to 40 of 42

Thread: [2005] Receive Gmail Mails using vb.net????

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    312

    [2005] Receive Gmail Mails using vb.net????

    Is there any way i can make a vb.net application that will allow me to retrieve the gmail inbox into my Application??

    I can use gmail Smtp server to send the mails , thats not the problem , the problem i m facing is that i cant receive the mails from gmail to my application

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2005] Receive Gmail Mails using vb.net????

    GMail supports POP3. You'd program it just like any other POP3 application. I know because I have Thunderbird pulling my GMail box.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [2005] Receive Gmail Mails using vb.net????

    Well, that's all fine and dandy, but Thunderbird still isn't VB.NET.

    I've only briefly looked into this, and I can't seem to find a POP3 namespace in .NET. I've found the SMTP namespace to send emails, but I haven't been able to find a way to read emails. That's not to say there isn't, jsut haven't really looked hard enough to find it.

    I'm sure there's a way, it probably involves a third-party component of some kind.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2005] Receive Gmail Mails using vb.net????

    No way! They have SMTP but no POP3?! I just kinda assumed if Microsoft built one into the framework, it would be natural to build the other.

    I also figured the problem was Raziiq didn't know GMail has POP3 capability. A lot of webmail systems don't.

  5. #5
    Addicted Member Zero2Cool's Avatar
    Join Date
    Aug 2006
    Location
    Green Bay, WI
    Posts
    203

    Re: [2005] Receive Gmail Mails using vb.net????

    I think maybe this link could help you.

  6. #6
    Member
    Join Date
    Jun 2003
    Posts
    42

    Re: [2005] Receive Gmail Mails using vb.net????

    gmail also supports imap. You just have to enable it in your account.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    312

    Re: [2005] Receive Gmail Mails using vb.net????

    Thanks for the replies.
    ya i know that gmail has smtp server as stmp.gmail.com but problem is that i cant find any method to get the inbox of my Gmail into my windows Application.
    I researched about it , there are so many 3rd party libraries around that if you buy can help , but what if i dont want to buy anything?? Is it that VB.net has no built in DLL's for this purpose?

  8. #8
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2005] Receive Gmail Mails using vb.net????

    Use the link Zero2Cool posted. It's a link to a home-made simple POP3 class. It's kinda ugly and could use a good cleanup, especially with how the errors are handled, but it works.

  9. #9
    New Member
    Join Date
    Apr 2009
    Posts
    4

    Re: [2005] Receive Gmail Mails using vb.net????

    Im still looking all over the web for a working gmail code. I just want a simple one that downloads and allows option for deleting gmail emails (no sending). Ive managed to develop the one posted above a little by adding the ssl required by gmail. I keep on getting an error at runtime. As soon as I click the download button it says "IOException was Unhandled" on the line in bold below. Im relatively new to VB, and Ive been struggling to find a working

    Imports System
    Imports System.Net.Sockets
    Imports System.Text
    Imports System.IO

    Module POP3Message1


    Dim Server As TcpClient
    Dim NetStrm As NetworkStream
    Dim RdStrm As StreamReader
    Dim _Strm As Net.Security.SslStream

    Public Function connect() As Integer
    Dim POP3Account As String
    POP3Account = "pop.gmail.com"
    If POP3Account.Trim = "" Then Exit Function
    Try
    Server = New TcpClient(POP3Account.Trim, 995)
    NetStrm = Server.GetStream
    _Strm = New Net.Security.SslStream(Server.GetStream())
    DirectCast(_Strm, Net.Security.SslStream).AuthenticateAsClient("pop.gmail.com")
    RdStrm = New StreamReader(Server.GetStream)
    Catch exc As Exception
    MsgBox(exc.Message)

    Exit Function
    End Try

    Dim user As String
    user = "******@gmail.com"
    Dim data As String = "USER " + user.Trim + vbCrLf
    Dim szData() As Byte = System.Text.Encoding.ASCII.GetBytes(data.ToCharArray())
    NetStrm.Write(szData, 0, szData.Length)
    Dim POPResponse As String
    POPResponse = RdStrm.ReadLine
    If POPResponse.Substring(0, 4) = "-ERR" Then
    MsgBox("Invalid user Name")
    Return -1
    End If
    Dim password As String
    password = "*******"
    data = "PASS " & password & vbCrLf
    szData = System.Text.Encoding.ASCII.GetBytes(data.ToCharArray())
    NetStrm.Write(szData, 0, szData.Length)
    POPResponse = RdStrm.ReadLine
    If POPResponse.Substring(0, 4) = "-ERR" Then
    MsgBox("Invalid Passwprd")
    Return (-1)
    End If
    data = "STAT" + vbCrLf
    szData = System.Text.Encoding.ASCII.GetBytes(data.ToCharArray())
    NetStrm.Write(szData, 0, szData.Length)
    POPResponse = RdStrm.ReadLine
    If POPResponse.Substring(0, 4) = "-ERR" Then
    MsgBox("could not log your in")
    Return -1
    End If
    data = "Stat" + vbCrLf
    szData = System.Text.Encoding.ASCII.GetBytes(data.ToCharArray())
    NetStrm.Write(szData, 0, szData.Length)
    POPResponse = RdStrm.ReadLine
    If POPResponse.Substring(0, 4) = "-ERR" Then
    MsgBox("could not log your in")
    Return -1
    End If
    Dim parts() As String
    parts = POPResponse.Split(" ")
    Dim messages, totsize As Integer

    'messages = parts(3)
    messages = CInt(parts(1))
    Return messages



    End Function
    Public Function DeleteMessage(ByVal msgIndex As Integer)
    Dim data As String = "DELE " & msgIndex.ToString & vbCrLf
    Dim SzData() As Byte = System.Text.Encoding.ASCII.GetBytes(data.ToCharArray())
    NetStrm.Write(SzData, 0, SzData.Length)
    Dim tmpString As String = RdStrm.ReadLine()
    If tmpString.Substring(0, 4) = "-ERR" Then
    MsgBox("Could Not Delete Message")
    Return (-1)
    Else
    Return 11
    End If
    End Function
    Public Function Quit()
    Dim data As String = "Quit " & vbCrLf
    Dim szData() As Byte = System.Text.Encoding.ASCII.GetBytes(data.ToCharArray())
    NetStrm.Write(szData, 0, szData.Length)
    Dim tmpString As String = RdStrm.ReadLine()
    End Function
    Public Structure Message
    Dim _From As String
    Dim _To As String
    Dim _Date As String
    Dim _Subject As String
    Dim _CC As String
    Dim _BCC As String
    Dim _Body As String
    Dim _Received As String
    End Structure
    Public Function CreateFromText(ByVal strMessage As String) As Message
    Dim Mssg As New Message
    Dim brkPos As Integer
    Dim Header As String
    Dim Headers() As String
    Dim Body As String
    Dim vField As Object
    Dim strHeader As String
    Dim HeaderName As String
    Dim HeaderValue As String


    brkPos = InStr(1, strMessage, vbCrLf & vbCrLf)
    If brkPos Then
    Header = strMessage.Substring(0, brkPos - 1)
    Body = strMessage.Substring(brkPos + 1, _
    strMessage.Length - Header.Length - 3)
    Mssg._Body = Body
    Else
    Throw New Exception("Invalid Message Format")
    Exit Function
    End If
    Headers = Split(Header, vbCrLf)
    Dim _header As String
    For Each _header In Headers
    brkPos = _header.IndexOf(":")
    If brkPos >= 0 Then
    HeaderName = _header.Substring(0, brkPos)
    Else
    HeaderName = ""
    End If
    HeaderValue = _header.Substring(brkPos + 1)
    Select Case HeaderName.ToLower
    Case "received"
    Mssg._Received = HeaderValue
    Case "from"
    Mssg._From = HeaderValue
    Case "to"
    Mssg._To = HeaderValue
    Case "cc"
    Mssg._CC = HeaderValue
    Case "bcc"
    Mssg._BCC = HeaderValue
    Case "subject"
    Mssg._Subject = HeaderValue
    Case "date"
    Mssg._Date = HeaderValue
    End Select
    Next
    Return Mssg
    End Function
    Function GetMessage(ByVal msgindex As Integer) As String
    Dim tmpString As String
    Dim Data As String
    Dim SzData() As Byte
    Dim msg As String
    Try
    Data = "RETR " & msgindex.ToString & vbCrLf
    SzData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
    NetStrm.Write(SzData, 0, SzData.Length)
    tmpString = RdStrm.ReadLine()
    If tmpString.Substring(0, 4) <> "-ERR" Then
    While (tmpString <> ".")
    msg = msg & tmpString & vbCrLf
    tmpString = RdStrm.ReadLine
    End While
    End If
    Catch exc As InvalidOperationException
    MsgBox("Message Retrival Failed: " & vbCrLf & Err.ToString())
    End Try
    Return msg
    End Function
    End Module

  10. #10
    New Member
    Join Date
    Apr 2009
    Posts
    4

    Re: [2005] Receive Gmail Mails using vb.net????

    Im using VB 2008 express if that helps.

  11. #11
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    Hi!
    Have u got a solution of ur problame?
    I try to insert a gmail mail downloader function in my app but iv got the same error message in the selected line:S

  12. #12
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: [2005] Receive Gmail Mails using vb.net????

    try putting those lines in a try/catch block and display the exception. actually... a LOT of that code should be put in Try/Catch blocks as I see a lot of potential parts that could return nothing or throw an error.

    also, for ease of reading to other forum readers, put your code in vb.net tags. formats it correctly and is a bit easier on the eyes when looking at that much code.

  13. #13
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    Hey,

    Seems like there are a few free components that will help you with this, rather than rolling your own:

    http://www.readypop.com/

    and:

    http://sourceforge.net/projects/hpop/

    To clarify, I haven't used either of these components, they were just found after a quick google.

    Gary

  14. #14
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    thanks gep13 i ll try it!

  15. #15
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    No problem.

    Let me know how you get on. Will be interesting to see if these components are any good.

    Gary

  16. #16
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    they doesn work coz they havent got ssl function:/ ajj

  17. #17
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    Hey,

    Let's clarify that. They do work, they support POP3, as request. You never said anything about supporting secure POP3.

    Gary

  18. #18
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    could u write me how can i set the ssl??I have no idea

  19. #19
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    Hey,

    Short answer is no. Off the top of my head I have no idea. It would take quite a bit of research. For something like this, I would be more inclined to go for a third party component, but that involves money.

    There are a couple out there:

    http://www.rebex.net/secure-mail.net/
    http://www.dart.com/ptmlnet.aspx

    At least that way you can get some support if things aren't working.

    Gary

  20. #20
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    i found something:
    http://www.codeproject.com/KB/IP/Pop3MailClient.aspx

    i imported the net.dll from the zip, but i dont know how can i see the mail with this...

    somebody have a solution for this problame but nobady write me answer on this link:
    http://www.vbforums.com/showthread.p...89#post3696789

  21. #21
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    Hey,

    Did you read the comments on the CodeProject link:

    I had a good experience using Gmail, although I encountered 2 flaws:

    - Gmail shows maximal 250-260 mails in a mailbox, even if there are thousands. Gmail shows the oldest emails. As soon some emails get deleted (after disconnect), newer emails get available.
    - The response of Gmail is sometimes slow and sometimes there is just no response.
    Have you tried using the source code from the CodeProject site directly? Does it work? I would start with getting that to work first, then start putting it into your own code.

    Gary

  22. #22
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    i cant open it coz it coding in vb 2005 and i have now vb 2008:/

  23. #23
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    Hey,

    Visual Studio 2008 should be able to convert it for you. Rather than open the solution file directly, just open up the project.

    Gary

  24. #24
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    here is some other solution but doesnt work for me:

    Re: [2005] Reading email
    Quote:
    Originally Posted by keon2005
    Does anyone here know how to do so. Seem to be tonnes of example on how to send but none of them is about reading email that is working properly.

    I need to read the email from the mail server that is in my intranet from my application server. Any expert here know how to do that?


    Goto

    http://www.codeproject.com/KB/IP/NetPopMimeClient.aspx

    At the very top of the article it says "Download Sourcecode"

    Save the sourcode to your desktop or where ever

    There is a folder within the zip file that is called NetPopMimeClient go in there, then go into the bin folder. You need to add Net.dll which is in that folder as a reference to your project then you can call any of the functions within it.


    Example of usage.

    Code:

    Dim pop3 As Net.Mail.Pop3Client = New Net.Mail.Pop3Client("My hostname", "myusername", "mypassword")

  25. #25
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    Hey,

    You seem to be jumping around quite a bit, and it is getting difficult to follow. Stick with one thing just now, and try and get it working, rather than trying lots of different ones.

    Gary

  26. #26
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    yeah i try to open it but vb 2008 give back error:/ so vb 2008 cant open it

  27. #27
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    What error did you get?

    I have just opened the solution in Visual Studio 2008 and it worked fine. The project conversion wizard popped up, and once completed, the solution opened up.

    Gary

  28. #28
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    i have visual Basic 2008 not vs 2008.
    it write me:the project file was unloaded :S

  29. #29
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    Hey,

    Ok, so now this is making more sense. The project is written in C#, so Visual Basic Express is never going to be able to open it.

    Can you also install C# Express Edition? That will let you open the application, and from there you can start to convert it over to VB.

    Gary

  30. #30
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    ok how can i do it??XDXD

  31. #31
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    How can you do what? Install C# Express Edition?

    Download it from here:

    http://www.microsoft.com/express/vcsharp/

    And install it. Open up the project, and away you go.

    Gary

  32. #32
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    ok i install it and i can open the project with it but how can i import this project to my visual basic project?:O

  33. #33

    Re: [2005] Receive Gmail Mails using vb.net????

    You can either convert the program to VB.net, or if it's a DLL, just compile it and add it as a reference to your program.

  34. #34
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    i try to open it in vb but it cant do it:s

  35. #35

    Re: [2005] Receive Gmail Mails using vb.net????

    You're clearly a newbie at this, so I'll give you a hand. Visual Studio won't convert the C# Code to VB.net for you. An Online Translator will however. Use this to translate the code.

  36. #36
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Receive Gmail Mails using vb.net????

    luke,

    Now that you have installed C#, you should be able to open the C# project in there (it may ask you to do a conversion, but that you run through without any problems). When I say conversion, I mean a C# conversion between Version 2005 and 2008, not between any of the languages.

    I was suggesting that you take a look at the C# code, look at what it's doing, identify the classes that it is using, and then, if you choose to, convert this over to VB. As formlesstree4 mentioned, there are some online convertors that will attempt to do this for you, but they are not always 100&#37; successful. I would give it smaller chunks of code at a time, that way it should be able to have a stab at it.

    If you don't want to go down this route, then you can always change the C# project to be a class library (DLL), and then simply reference this DLL in your VB project.

    Ask if there is anything you are not sure about.

    Gary

  37. #37
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    ohh many thanks for everyone!!!
    Now its working working.I can download the mails from gmail.I try to post the code here but its too long:/
    And i have a new problame.
    How can i set a proxy for a pop3 mailserver??
    Could anybody tell me how could i find it that which webclient is used by the pop3 server???
    I try to set proxy with this code but nothing happened,any idea??


    vb Code:
    1. Dim wp As New WebProxy(txtproxy.Lines(proxynumber), False)
    2.  
    3.             GlobalProxySelection.Select = wp

  38. #38
    Junior Member
    Join Date
    Nov 2009
    Posts
    17

    Re: [2005] Receive Gmail Mails using vb.net????

    the "connect" part of the pop3 mail client code:
    Code:
     Public Sub Connect()
                    If m_pop3ConnectionState <> Pop3ConnectionStateEnum.Disconnected AndAlso m_pop3ConnectionState <> Pop3ConnectionStateEnum.Closed AndAlso Not isTimeoutReconnect Then
                        CallWarning("connect", "", "Connect command received, but connection state is: " & m_pop3ConnectionState.ToString())
                    Else
                        'establish TCP connection
                        Try
                            CallTrace(" Connect at port {0}", m_port)
                            serverTcpConnection = New TcpClient(m_popServer, m_port)
                        Catch ex As Exception
                            Throw New Pop3Exception((("Connection to server " & m_popServer & ", port ") + m_port & " failed." & vbLf & "Runtime Error: ") + ex.ToString())
                        End Try
    
                        If m_useSSL Then
                            'get SSL stream
                            Try
                                CallTrace(" Get SSL connection")
                                pop3Stream = New SslStream(serverTcpConnection.GetStream(), False)
                                pop3Stream.ReadTimeout = m_readTimeout
                            Catch ex As Exception
                                Throw New Pop3Exception(("Server " & m_popServer & " found, but cannot get SSL data stream." & vbLf & "Runtime Error: ") + ex.ToString())
                            End Try
    
                            'perform SSL authentication
                            Try
                                CallTrace(" Get SSL authentication")
                                DirectCast(pop3Stream, SslStream).AuthenticateAsClient(m_popServer)
                            Catch ex As Exception
                                Throw New Pop3Exception(("Server " & m_popServer & " found, but problem with SSL Authentication." & vbLf & "Runtime Error: ") + ex.ToString())
                            End Try
                        Else
                            'create a stream to POP3 server without using SSL
                            Try
                                CallTrace(" Get connection without SSL")
                                pop3Stream = serverTcpConnection.GetStream()
                                pop3Stream.ReadTimeout = m_readTimeout
                            Catch ex As Exception
                                Throw New Pop3Exception(("Server " & m_popServer & " found, but cannot get data stream (without SSL)." & vbLf & "Runtime Error: ") + ex.ToString())
                            End Try
                        End If
                        'get stream for reading from pop server
                        'POP3 allows only US-ASCII. The message will be translated in the proper encoding in a later step
                        Try
                            pop3StreamReader = New StreamReader(pop3Stream, Encoding.ASCII)
                        Catch ex As Exception
                            If m_useSSL Then
                                Throw New Pop3Exception(("Server " & m_popServer & " found, but cannot read from SSL stream." & vbLf & "Runtime Error: ") + ex.ToString())
                            Else
                                Throw New Pop3Exception(("Server " & m_popServer & " found, but cannot read from stream (without SSL)." & vbLf & "Runtime Error: ") + ex.ToString())
                            End If
                        End Try
    
                        'ready for authorisation
                        Dim response As String
                        If Not readSingleLine(response) Then
                            Throw New Pop3Exception(("Server " & m_popServer & " not ready to start AUTHORIZATION." & vbLf & "Message: ") + response)
                        End If
                        setPop3ConnectionState(Pop3ConnectionStateEnum.Authorization)
    
                        'send user name
                        If Not executeCommand("USER " & m_username, response) Then
                            Throw New Pop3Exception((("Server " & m_popServer & " doesn't accept username '") + m_username & "'." & vbLf & "Message: ") + response)
                        End If
    
                        'send password
                        If Not executeCommand("PASS " & m_password, response) Then
                            Throw New Pop3Exception(((("Server " & m_popServer & " doesn't accept password '") + m_password & "' for user '") + m_username & "'." & vbLf & "Message: ") + response)
    
                        End If
    
    
                        setPop3ConnectionState(Pop3ConnectionStateEnum.Connected)
                        End If
                End Sub

  39. #39
    New Member
    Join Date
    Dec 2010
    Posts
    2

    Talking Re: [2005] Receive Gmail Mails using vb.net????

    Hi luke could you please post the full project source in zip or rar format I am new to this also I just finished making a mail sender that works with gmail, yahoo mail, msn, and aol mail and would now like to make a email reader to go with it. I will post my project for all the people here also here:

    http://www.mediafire.com/?1x3qnbs1m2bywfq

    Plus here is the code for people who do not wish to download:

    Form1 Login form (Just takes login credentials and stores to global variables)
    Code:
    Imports System.Net.Mail
    Public Class Form1
    
        'Declares variables needed to store unique email details
        Public Shared mail As String
        Public Shared password As String
        Public Shared smtp As String
        Public Shared send_to As String
        Public Shared SMTPServer As New SmtpClient(Form1.smtp)
        
        Private Sub btnGmailLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGmailLogin.Click
            'Allocate the details from text boxes to the variables called by
            'the meat of the program (Vorfins mail source)
            mail = GmailUser.Text
            password = GmailPass.Text
            smtp = ("smtp.gmail.com")
            Me.Hide()
            Form2.Show()
        End Sub
    
       
        Private Sub btnMsnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMsnLogin.Click
            'Allocate the details from text boxes to the variables called by
            'the meat of the program (Vorfins mail source)
            mail = MsnUser.Text
            password = MsnPass.Text
            smtp = ("smtp.live.com")
            Me.Hide()
            Form2.Show()
        End Sub
    
        Private Sub btnYahooLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYahooLogin.Click
            'Allocate the details from text boxes to the variables called by
            'the meat of the program (Vorfins mail source)
            mail = YahooUser.Text
            password = YahooPass.Text
            smtp = ("smtp.mail.yahoo.com")
            Form1.SMTPServer.EnableSsl = False
            Me.Hide()
            Form2.Show()
        End Sub
    
        Private Sub btnAimLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAimLogin.Click
            'Allocate the details from text boxes to the variables called by
            'the meat of the program (Vorfins mail source)
            mail = AimUser.Text
            password = AimPass.Text
            smtp = ("smtp.aol.com")
            Me.Hide()
            Form2.Show()
        End Sub
    End Class
    Form2 (Actual Email Sender) Yahoo does not work with SSL so if else statement was used )
    Code:
    Imports System.Net.Mail
    Public Class Form2
    
        Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
            If Form1.smtp = ("smtp.mail.yahoo.com") Then
                'Vorfins mail sender source.
                'Inputs all appropriate information for mail import to send the email. 
                Dim MyMailMessage As New MailMessage
                Try
                    MyMailMessage.From = New MailAddress(Form1.mail)
                    MyMailMessage.To.Add(txtSendTo.Text)
                    MyMailMessage.Subject = (txtSubject.Text)
                    MyMailMessage.Body = (txtBody.Text)
                    Dim SMTPServer As New SmtpClient(Form1.smtp)
                    SMTPServer.Port = 587
                    SMTPServer.Credentials = New System.Net.NetworkCredential(Form1.mail, Form1.password)
                    SMTPServer.EnableSsl = False
                    SMTPServer.Send(MyMailMessage)
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
    
            Else
    
                'declare variable to hold sender email
                'assign textbox for "Send to" to this variable 
                Form1.send_to = txtSendTo.Text
    
                'Vorfins mail sender source.
                'Inputs all appropriate information for mail import to send the email. 
                Dim MyMailMessage As New MailMessage
                Try
                    MyMailMessage.From = New MailAddress(Form1.mail)
                    MyMailMessage.To.Add(txtSendTo.Text)
                    MyMailMessage.Subject = (txtSubject.Text)
                    MyMailMessage.Body = (txtBody.Text)
                    Dim SMTPServer As New SmtpClient(Form1.smtp)
                    SMTPServer.Port = 587
                    SMTPServer.Credentials = New System.Net.NetworkCredential(Form1.mail, Form1.password)
                    SMTPServer.EnableSsl = True
                    SMTPServer.Send(MyMailMessage)
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
    
            End If
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            'This tells the program to go back to the login page for when the
            'user wants to send a mail from a different account.
            Me.Hide()
            Form1.Show()
    
        End Sub
    End Class
    I am also a noob programmer I got the first tutorial from here: http://leetcoders.org/showthread.php?tid=1187

    and found it to be really interesting so added on it. As far as i am aware there are no multi email platform sources and tuts around so this should at least be a little bit helpful. PLEASE POST YOUR SOURCE LUKE!!! Lol

  40. #40
    Member
    Join Date
    Aug 2002
    Posts
    58

    Re: [2005] Receive Gmail Mails using vb.net????

    If you got the DLL working can you send it along so others can try it out? I'm trying to connect gmail as well.
    -------------------------------
    StupidMonkee

Page 1 of 2 12 LastLast

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