Hi eppdevlop,
For fetch and read the email refer below article.
For saving the attachments in folder check with the below code.
C#
protected void Save(object sender, EventArgs e)
{
foreach (GridViewRow row in gvEmails.Rows)
{
List<Attachment> attachments = this.Emails.Where(email => email.MessageNumber == Convert.ToInt32(gvEmails.DataKeys[row.RowIndex].Value)).FirstOrDefault().Attachments;
foreach (Attachment attachment in attachments)
{
if (attachment.Content.Length > 0)
{
string path = Server.MapPath("~/Attachments/") + attachment.FileName;
File.WriteAllBytes(path, attachment.Content);
}
}
}
}
VB.Net
Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs)
For Each rows As GridViewRow In gvEmails.Rows
Dim row As GridViewRow = rows
Dim attachments As List(Of Attachment) = Me.Emails.Where(Function(email) email.MessageNumber = Convert.ToInt32(gvEmails.DataKeys(row.RowIndex).Value)).FirstOrDefault().Attachments
For Each attachment As Attachment In attachments
If attachment.Content.Length > 0 Then
Dim path As String = Server.MapPath("~/Attachments/") + attachment.FileName
File.WriteAllBytes(path, attachment.Content)
End If
Next
Next
End Sub