Email attachments are not showing up
image.png (14.0 KB)
Thanks for the screenshot.
We could not understand your issue. Please provide more details on the issue you are encountering with Aspose.Cells, including the specific APIs you are using? Are you using Aspose.Email? Please share your sample (runnable) code using the Aspose APIs and attach any relevant sample files (please zip them prior attaching) to demonstrate the issue. We will check your issue and assist you accordingly.
MimeMessage message = new MimeMessage();
message.From.Add(new MailboxAddress(“Sender Name”, “”));
var multipart = new Multipart(“mixed”);
multipart.Add(new TextPart(MimeKit.Text.TextFormat.Html)
{
Text = “Good morning current production schedule will show any work order start date changes from the prior day’s report”
});
Workbook workbookExportList = new Workbook();
workbookExportList.Worksheets.Clear();
Worksheet worksheetWithExportedList = workbookExportList.Worksheets.Add("Data");
worksheetWithExportedList.Cells.ImportCustomObjects((System.Collections.ICollection)histInfo,
new string[] { "Id", "Resource" , "WorkOrder", "Part","Description","Quantity","StartDateOld",
"StartDateNew","DaysPushedPull","Complete","ColorAndDescription","Notes"},
true, 1, 0, histInfo.Count, true, "mm/dd/yyyy", false);
for(int row = 2;row < worksheetWithExportedList.Cells.MaxRow + 1; row++)
{
Cell cell = worksheetWithExportedList.Cells[row,8];
Style st = worksheetWithExportedList.Cells.Rows[row].GetStyle();
st.Pattern = BackgroundType.Solid;
StyleFlag flag = new StyleFlag();
flag.CellShading = true;
if (cell.Value is int cellValue && cellValue > 0)
{
st.ForegroundColor = System.Drawing.Color.FromArgb(255, 219, 187);
}
else
{
st.ForegroundColor = System.Drawing.Color.FromArgb(144, 238, 144);
}
worksheetWithExportedList.Cells.Rows[row].ApplyStyle(st, flag);
}
string dirName = AppDomain.CurrentDomain.BaseDirectory;
string fileName = Path.Combine(dirName, string.Format("{0} {1} WorkOrder Start Date Changes of Prior day {2}{3}", day.ToString("MMMM"),
day.Year, day.ToString("MM.dd.yy"), ".xlsx"));
workbookExportList.Save(fileName);
var attachment = new MimePart("application", "vnd.openxmlformats-officedocument.spreadsheetml.sheet")
{
Content = new MimeContent(System.IO.File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)),
ContentDisposition = new MimeKit.ContentDisposition(MimeKit.ContentDisposition.Attachment),
ContentTransferEncoding = ContentEncoding.Binary,
FileName = Path.GetFileName(fileName)
};
//htmlTable.Attachments.Add(attachment);
multipart.Add(attachment);
//message.Body = htmlTable.ToMessageBody();
message.Body = multipart;
using (var client = new MailKit.Net.Smtp.SmtpClient())
{
client.Connect("smtp.office365.com", 587, SecureSocketOptions.StartTls);
client.Authenticate("", "");
client.Send(message);
client.Disconnect(true);
}
I am not using aspose email i m using mime kit to send the attachment but the attachment is not showing up for iphone users mail default app. do you still need an sample excel file ? I am using aspose cells with latest version 24.0.0 asp.net mvc .net 4.6.1
I checked your code segment regarding Aspose.Cells. There are certain collection/list and other objects for which I am not sure. Anyways, I tested and used a dynamic List (created in code) and added certain records to it. I imported data from the list using ImportCustomObjects to Excel worksheet via Aspose.Cells. Then I applied the formatting for shading/background color to the rows (cells). Finally I saved the Excel file to file path via Aspose.Cells for .NET APIs. It works fine and the output Excel file is fined tuned. So, your issue is not related to Aspose.Cells APIs but it is related to mime kit/tool you are using which sends mail with attachments. Please evaluate your code segment which uses mime tool and fix it by yourselves.
In case you still think the issue is with Aspose.Cells and output Excel file is not generated fine or has some other issues, kindly let us know with details and samples. We will check it soon.
figured out the issue thank u instead of mimekit tried to use system.net.mail.message is working fine
@schinamanagonda
Thank you for your feedback. I’m glad your issue has been resolved. If you have any questions, please feel free to contact us at any time.