nccsbim071 25 Junior Poster

Hi, I have used an open source code from codeproject to read email from incoming mail server(POP Server). The code can be found at following location: http://www.codeproject.com/KB/IP/Pop3MimeClient.aspx

So far it works fine i can read emails.

My objective of using this code was to retrieve emails from POP server and process them.

My problem is: If i use gmails pop server "pop.gmail.com" and run the appplication. I get only those emails that i have not retrieved since the last time i run the application. but if i use my clients pop server everytime i run the application i get all the emails in the pop server.

for example: If i use gmail pop server: pop.gmail.com I have three emails in the pop server. I haven't run the application. I am running the application for the first time. Application reads the email, this time i will get 3 all the three email. I run the application second time, my application will not read any emails this time because i have already read the 3 existing one. This is fine, this is what i want. Now i send email to pop.gmail.com. I run the application again for the third time, this time i will only get the email that has just arrived that is the fourth one. This is good behaviour, this is what i want.

But if i use my clients pop server: No matter how many times i run …

kvprajapati commented: Good question, indeed! +10
nccsbim071 25 Junior Poster

I got my answer here: ASP.NET AJAX CHAT

The names i am referring to below is from above link:

i think the actual problem was with the timestamp thing and asynchronous behaviour of $.post. after calling "GetMessages()" method, even if the previous request to retrive chat message was not complete anathor call to same method used to fire due to setting timeout for "GetMessages()" method outside the $.post method. In my question you can see that timeout for "GetMessages()" method is set outside the $.post method. Now i set the timeout for "GetMessages()" method inside the $.post method. so that next call to "GetMessages()" only occur after 3 seconds of completion of current $.post method. I have posted the code below.

var t;
        function GetMessages() {
            var LastMsgRec = $("#hdnLastMsgRec").val();
            var RoomId = $("#hdnRoomId").val();
            //Get all the messages associated with this roomId
            $.post("/Chat/GetMessages", { roomId: RoomId, lastRecMsg: LastMsgRec }, function(Data) {
                if (Data.LastMsgRec.length != 0)
                    $("#hdnLastMsgRec").val(Data.LastMsgRec);
                if (Data.Messages.length != 0) {
                    $("#messagesCont").append(Data.Messages);
                    if (Data.newUser.length != 0)
                        $("#usersUl").append(Data.newUser);
                    $("#messagesCont").attr({ scrollTop: $("#messagesCont").attr("scrollHeight") - $('#messagesCont').height() });
                    $("#userListCont").attr({ scrollTop: $("#userListCont").attr("scrollHeight") - $('#userListCont').height() });
                }
                else {
                }
                t = setTimeout("GetMessages()", 3000);
            }, "json");

        }

I addition to that i also changed few things. As suggested by ignatandrei i placed $("#hdnLastMsgRec").val(Data.LastMsgRec); immediately after function(Data) {.

and also

as said by MikeSW i changed the data retrieval process. Previously i was extracting data on the basis of timespan(retrieve all the data associated with
this room id that has …

nccsbim071 25 Junior Poster

thanks adatapost, reading the article helped me solved my problem.

I also aked the same question on www.stackoverflow.com and i got the solution there. click here for solution.

kvprajapati commented: Thanks! +8
nccsbim071 25 Junior Poster

It's long but simple. I have only explained the problem in detail.

After searching a lot i did not get any answers and finally i had to get back to you. Below i am explaining my problem in detail. It's too long, so please don't quit reading. I have explained my problem in simple language.

I have been developing an asp.net mvc project. I am using standard ASP.NET roles and membership. Everything is working fine but the remember me functionality doesn't work at all. I am listing all the details of work. Hope you guys can help me out solve this problem.

I simply need this:

I need user to login to web application. During login they can either login with remember me or without it. If user logs in with remember me, i want browser to remember them for long time, let's say atleast one year or considerably long time. The way they do it in www.dotnetspider.com,www.codeproject.com,www.daniweb.com and many other sites. If user logs in without remember me, then browser should allow access to website for some 20 -30 minutes and after that their session should expire. Their session should also expire when user logs in and shuts down the browser without logging out.

Note: I have succesfully implemented above functionality without using standard asp.net roles and membership by creating my own talbes for user and authenticating against my database table, setting cookie and …

nccsbim071 25 Junior Poster

Hi everybody
I have been developing windows client application in .net framework 3.5. The system is supposed to copy the remote mysqldb and restore my local mysqldb with all the schema and data withing remote schema to my local mysqldb with the same database name.

Well i found a solution to this using a mysqldump command and executing it from .net by writing all the necessary command in a bat file and executing the bat file by invoking from .net.

But i was looking for a better solution.

The way we make a sqlserver db backup and restore usig SqlServer.Smo package in .net


I there any way to make a database backup and restore using mysql.data.client. or just copy my remote mysql database to my local mysql database. all using mysql.data.client.

Thanks

nccsbim071 25 Junior Poster

Here is your solution:
Just replace your try catch block with my code and it will work:

Here is my code

try
        {
            using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader("TestFile.txt"))
                {
                    String line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        Console.WriteLine(line);

                        using (StreamWriter sw = new StreamWriter("TestFile.txt"))
                        {

                            sw.Write("\n");
                            sw.WriteLine("line\n");
                            sw.WriteLine("test");

                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            // Let the user know what went wrong.
            Console.WriteLine("The file could not be read:");
            Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
            Console.WriteLine("File: " + e.Name);
            Console.WriteLine("Folder:" + Path.GetDirectoryName(e.FullPath));
            Console.WriteLine(d.Message);
            continue;
        }

And I have few suggestions for you:
1. While writing code every time you open a bracket immediately place it's corresponding closing bracket and then go back inside the bracket and then type. This rule applies not only to brackets but for all the codes which has corresponding opening and closing code. For example doublequotes(") and single quotes(') and all of them.

2. When you post your code on Daniweb always enclose the code in code tags like this "

string str = "this is a string";

"

This will display as

string str = "this is a string";

Well goodluck
If you have any problem send messages directly at
info@bizpersonnel.com


www.bizpersonnel.com
A Software development Company

ddanbe commented: Good explanation. +7