SIGN UP MEMBER LOGIN:    
ARTICLE

Email Notifier with Microsoft Agent--- GENIE

Posted by Levent Camlibel Articles | Internet & Web November 16, 2001
Email notifier with Microsoft Agent is a TCP/IP application that notifies the user if there is email in the user's email server.
Reader Level:
Download Files:
 

Description 

Email notifier is TCP/IP application that notifies the user if there is email in the user's email server. This application checks email in default time interval of 5 minutes. You can change it with configure menu. this application is a Iconfied application. What I mean is that when you run it, it will appear in the right bottom corner as a icon. When you mouse right-click on it, you will see



If you choose Configure menu, you can configure settings, and you will see 



then you can configure

-POP3 Server

-POP3 Server Port

-User Name and Password

--Time Internal that the application checks email

I suggest you that you should enter these information, before you choose the menu "Check Email"

I improved this application by using Microsoft Agent character Genie. Genie will tell you how many emails you have. First of all you have to download Microsoft Agent SDK from the following URL and install it.

http://www.microsoft.com/msagent/downloads.htm



Genie will pop up and tells you the number of email

the following code makes Microsoft Agents work

public frmAgent(int EmailNumber)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
///you can download Agents from
///http://www.microsoft.com/msagent/downloads.htm
/// first load the character
Agent1.Characters.Load("Genie","Genie.acs");
AgentObjects.IAgentCtlCharacterEx genie=Agent1.Characters["Genie"];
AgentObjects.IAgentCtlRequest reg;
genie.Show(
false);
genie.Speak("You Have "+ EmailNumber.ToString()+" emails","");
genie.Think("Should I Leave or Stay, Himmm!!!!");
genie.Hide(
true);
}

Source Code:

private void EmailCheck()
{
TcpClient tcpClient =
new TcpClient();
try
{
tcpClient.Connect(txtPopServer.Text,Int32.Parse(txtPopPort.Text));
}
catch
{
MessageBox.Show("Cannot connect to target host "+txtPopServer.Text +" and port "+txtPopPort.Text);
}
///get the response of pop3 mail server
netStream = tcpClient.GetStream();
if(netStream == null)
{
throw new Exception("GetStream is null");
}
string returnMsg=ReadFromNetStream(ref netStream);
checkForError(returnMsg);
///send username information
WriteToNetStream(ref netStream, "USER " + this.txtUserName.Text);
returnMsg=ReadFromNetStream(
ref netStream);
checkForError(returnMsg);
///send password information
WriteToNetStream(ref netStream, "PASS " + this.txtPassword.Text);
returnMsg=ReadFromNetStream(
ref netStream);
checkForError(returnMsg);
Stat();
netStream.Close();
tcpClient.Close();
}
public void Stat()
{
WriteToNetStream(
ref netStream, "STAT");
string returnMsg=ReadFromNetStream(ref netStream);
checkForError(returnMsg);
///split the information of total message and total size
string[] TotalStat= returnMsg.Split(new char[] {' '});
int count=Int32.Parse(TotalStat[1]);
int totalSize=Int32.Parse(TotalStat[2]);
///the following code will call the Microsoft Agent (Genie Chracter)
frmAgent agent= new frmAgent(count); 
emailnot.Show();
}
private void WriteToNetStream(ref NetworkStream NetStream, string Command)
{
string stringToSend = Command + "\r\n";
Byte[] arrayToSend = Encoding.ASCII.GetBytes(stringToSend.ToCharArray());
NetStream.Write(arrayToSend, 0, arrayToSend.Length);
}
/// <summary>
///
this function reads from Network Stream
/// </summary>
///
<param name="NetStream"></param>
///
<returns></returns>
private String ReadFromNetStream(ref NetworkStream NetStream)
{
StringBuilder strReceived=
new StringBuilder();
StreamReader sr=
new StreamReader(NetStream);
String strLine = sr.ReadLine();
while(strLine==null || strLine.Length==0)
{
strLine = sr.ReadLine();
}
strReceived.Append(strLine);
if(sr.Peek()!=-1)
{
while ((strLine=sr.ReadLine())!=null)
{
strReceived.Append(strLine);
}
}
return strReceived.ToString();
}
/// <summary>
///
this function checks the error in the stream;
/// </summary>
///
<param name="s"></param>
private void checkForError(String strMessage)
{
if (strMessage.IndexOf("+OK") == -1)
throw new Exception("ERROR - . Recieved: " + strMessage);
}

Login to add your contents and source code to this article
share this article :
post comment
 

How can Install the genie computer programme to my computer and how can I know is there?

Posted by Rieziel Golipardo Sep 05, 2011

hello,
thank u for providing this code but i getting this error ...can u help me about this error?
i entered my gmail user account and add "pop.gmail.com"in Emailserver textbox

ERROR - . Recieved: -ERR Cannot connect to POP server 74.125.127.109 (74.125.127.109:110), connect error 10060

Posted by Nitin Makwana Feb 03, 2010
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor