public async void AttachmentMethod(List<GridViewClass> viewCollection,string emailDetails)
{
string headerTemplate = @"""Project Id""" + "," + @"""Project Name""" + "," + @"""Type""" + "," + @"""PBID""" + "," + @"""Priority""" + "," + @"""Module""" + "," + @"""Phase""" + "," + @"""Title""" + "," + @"""Acceptance Crieteria""" + "," + @"""Status""" + "," + @"""Resource""" + "," + @"""Sprint""" + "," + @"""Comments""" + "," + @"""Estimated Hours""" + "," + @"""Actual Hours""" + "," + @"""Remaining Hours""" + " \n";
foreach (GridViewClass item in viewCollection)
{
headerTemplate += "\"" + item.ProjectId.ToString() + "\"" + "," + "\"" + item.ProjectName + "\"" + "," + "\"" + item.Type + "\"" + "," + "\"" + item.PBID + "\"" + "," + "\"" + item.Priority + "\"" + "," + "\"" + item.Module + "\"" + "," + "\"" + item.Phase + "\"" + "," + "\"" + item.TaskDescription + "\"" + "," + "\"" + item.AcceptanceCriteria + "\"" + "," + "\"" + item.Status + "\"" + "," + "\"" + item.Resource + "\"" + "," + "\"" + item.SprintId + "\"" + "," + "\"" + item.Comments + "\"" + "," + "\"" + item.EstimatedHours.ToString() + "\"" + "," + "\"" + item.ActualHours.ToString() + "\"" + "," + "\"" + item.RemainigHours.ToString() + "\"" + "\n";
}
try
{
var localAppFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
var fileHandle = await localAppFolder.CreateFileAsync("Fiel.csv", Windows.Storage.CreationCollisionOption.ReplaceExisting);
await Windows.Storage.FileIO.WriteTextAsync(fileHandle, headerTemplate);
//var string=await Windows.Storage.FileIO.ReadTextAsync(fileHandle);
var emailMessage = new Windows.ApplicationModel.Email.EmailMessage();
emailMessage.Body = "Hi Sir,Thank you so much for suggesting me";
emailMessage.Subject = "Thank you sir..";
var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(emailDetails);
var emailAttachement = new Windows.ApplicationModel.Email.EmailAttachment();
emailAttachement.FileName = "fileHandle.csv";
emailAttachement.Data=fileHandle;
emailMessage.To.Add(emailRecipient);
emailMessage.Attachments.Add(emailAttachement);
await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(emailMessage);
}
catch (Exception)
{
}
}