Hello all,
As i am new to the asp.net,so need your help in solving my queries
i want to retrieve only the message part of the body ,no trimmed content should be retrieved from the inbox of the gmail.I am able to retrieve the message part but also getting the trimmed content.Meanwhile i have to insert only the message of body in the database,but as i am getting the trimmed content also so,the whole message body along with the trimmed content is inserted.So plz help me,regarding the above ,to insert only the message body in the database/retrieve only the message body(no trimmed content)
Loading
Jolly PriyaPosted Sep 18, 2013, 3:07 AM
Iftikar HussainPosted Sep 18, 2013, 1:40 AM
Jolly PriyaPosted Sep 18, 2013, 1:29 AM
i have two pages
1:to show the sub,date and sender mail in gridview:
Emailretrieve.aspx.cs
This will work on clicking of a button:
C# coding:
Pop3Client pop3Client;
if (Session["Pop3Client"] == null)
{
pop3Client = new Pop3Client();
pop3Client.Connect(txtMailServer.Text, int.Parse(txtPort.Text), chkSSL.Checked); pop3Client.Authenticate(txtEmail.Text, txtPassword.Text); Session["Pop3Client"] = pop3Client;
}
else
{
pop3Client = (Pop3Client)Session["Pop3Client"];
}
int count = pop3Client.GetMessageCount();
DataTable dtMessages = new DataTable();
dtMessages.Columns.Add("MessageNumber");
dtMessages.Columns.Add("From");
dtMessages.Columns.Add("Subject");
// dtMessages.Columns.Add("Body");
dtMessages.Columns.Add("DateSent");
int counter = 0; for (int i = count; i >= 1; i--)
{
Message message = pop3Client.GetMessage(i);
dtMessages.Rows.Add();
dtMessages.Rows[dtMessages.Rows.Count - 1]["MessageNumber"] = i; dtMessages.Rows[dtMessages.Rows.Count - 1]["From"] = message.Headers.From.Address; dtMessages.Rows[dtMessages.Rows.Count - 1]["Subject"] = message.Headers.Subject; dtMessages.Rows[dtMessages.Rows.Count - 1]["DateSent"] = message.Headers.DateSent.ToLocalTime(); counter++;
gvEmails.DataSource = dtMessages;
gvEmails.DataBind();
Email retrieve.Aspx page:
Subject column of gridview is hyperlinked field which uses querystring paramenter:
Show message.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Pop3Client pop3Client = (Pop3Client)Session["Pop3Client"];
string mn = HttpUtility.UrlDecode(Request.QueryString["MessageNumber"]);
int messageNumber=int.Parse(mn);
lbldate.Text = HttpUtility.UrlDecode(Request.QueryString["DateSent"]);
Message message = pop3Client.GetMessage(messageNumber);
MessagePart messagePart = message.MessagePart.MessageParts[0];
lblFrom.Text = message.Headers.From.Address;
lblSubject.Text = message.Headers.Subject;
lblBody.Text = messagePart.BodyEncoding.GetString(messagePart.Body);
}
Iftikar HussainPosted Sep 18, 2013, 1:15 AM
Can you please share your code?