Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
any way i have successfully complete sending mails programmatically,but i want to read any mails means (either gmail,yahoo,live...etc)
How to read any mail programmatically
let me know






Thanks and advance.
Posted
Updated 12-Jan-12 19:40pm
v3
Comments
Prerak Patel 13-Jan-12 1:03am    
What do you mean by 'any mail'? How exactly you want it?
Bojjaiah 13-Jan-12 1:13am    
any way i have successfully complete sending mails programmatically,but i want to read any mails means (either gmail,yahoo,live...etc)

you have to use the POP of the mail server

see this link[^]

thanks
 
Share this answer
 
 
Share this answer
 
v2
reading gmail like this,

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim objClient As New System.Net.WebClient
Dim nodelist As XmlNodeList
Dim node As XmlNode
Dim response As String
Dim xmlDoc As New XmlDocument
Try

objClient.Credentials = New System.Net.NetworkCredential(UsernameTextBox.Text.Trim, PasswordTextBox.Text.Trim)
response = Encoding.UTF8.GetString(objClient.DownloadData("https://mail.google.com/mail/feed/atom"))
response = response.Replace("", "<feed>")

xmlDoc.LoadXml(response)
node = xmlDoc.SelectSingleNode("/feed/fullcount")
mailCount = node.InnerText 'Get the number of unread emails

If mailCount > 0 Then
ReDim emailFrom(mailCount - 1)
ReDim emailMessages(mailCount - 1)
nodelist = xmlDoc.SelectNodes("/feed/entry")
node = xmlDoc.SelectSingleNode("title")

For Each node In nodelist
emailMessages(tempCounter) = node.ChildNodes.Item(0).InnerText
emailFrom(tempCounter) = node.ChildNodes.Item(6).ChildNodes(0).InnerText
tempCounter += 1
Next
tempCounter = 0
End If
Me.Hide()
Form1.Show()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
//another form
VB
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Timer1.Enabled = True
       Me.Hide()
       Me.ShowInTaskbar = False
       Left = (SystemInformation.WorkingArea.Size.Width - Size.Width)
       Top = (SystemInformation.WorkingArea.Size.Height - Size.Height)
   End Sub

   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
       Me.Show()
       If tempCounter >= mailCount Then
           Timer1.Enabled = False
           Me.Hide()
       Else
           lblFrom.Text = "From : " & emailFrom(tempCounter)
           lblMessage.Text = "Subject : " & emailMessages(tempCounter)
           tempCounter += 1
       End If

   End Sub


//glabalvariable.vb
SQL
Public emailFrom(1), emailMessages(1) As String
   Public tempCounter As Int16 = 0
   Public mailCount As Int16 = 0
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900