---
title: "How to use this code in WPF Application with MVVM"  
description: "How to use this code in WPF Application with MVVM"  
author: "Santosh Kumar Singh"  
published: 2014-12-04  
updated: 2014-12-04  
canonical: https://www.mindstick.com/forum/12742/how-to-use-this-code-in-wpf-application-with-mvvm  
category: ".net"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How to use this code in WPF Application with MVVM

Hello [friends](https://answers.mindstick.com/qa/31396/where-did-the-suggest-to-friends-feature-go) You have any [ideas](https://www.mindstick.com/articles/43878/making-the-best-use-of-the-options-trade-ideas) please share with us.

```
  Imap4Client imap = new Imap4Client();            imap.ConnectSsl("imap.gmail.com", 993);            imap.Login("heythatsme@gmail.com", "heythatsmypassword");            imap.Command("capability");
            Mailbox inbox = imap.SelectMailbox("inbox");int[] ids = inbox.Search("UNSEEN");if (ids.Length > 0)            {                Message msg_first = inbox.Fetch.MessageObject(ids[0]);                                //ignore this gmail_data stuff // undefined in this scope // checking to make sure it's a "new" unread msgif (gmail_data != msg_first.Date.ToString())                {                    gmail_data = msg_first.Date.ToString();
                    XElement xmail = new XElement("gmail",new XAttribute("count", ids.Length.ToString()),new XAttribute("modified", msg_first.Date.ToString())                    );string name = "", address = "", from = "";                    Regex reg_name = new Regex("\"[^\"]+");                    Regex reg_address = new Regex("<[^>]+");
                    Message msg = null;for (var i = 0; i < ids.Length; i++)                    {                        msg = inbox.Fetch.MessageObject(ids[i]);from = msg.HeaderFields["from"];                        name = reg_name.Match(from).Value.Replace("\"", "");                        address = reg_address.Match(from).Value.Replace("<", "");
                        xmail.Add(new XElement("entry",new XAttribute("id", msg.MessageId),new XAttribute("modified", msg.Date.ToString()),new XAttribute("name", name),new XAttribute("address", address),new XElement("subject", msg.Subject),new XElement("body-text", msg.BodyText.TextStripped),new XElement("body-html", msg.BodyHtml.Text)                        ));                    }
                                        File.WriteAllText(@"E:\srv\pub\http\interop\feeds\gmail.xml", xmail.ToString());                                                        }            }
```


---

Original Source: https://www.mindstick.com/forum/12742/how-to-use-this-code-in-wpf-application-with-mvvm

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
