Hi
I am getting error here - Attachment is not null here - message.Attachments.Add((System.Net.Mail.Attachment)attachment);
SAPbobsCOM.Attachment attachment = new SAPbobsCOM.Attachment();
attachment.FileName = @"10.0.1.30\SAP_Attachments\Outgoing Payments_204673_20250314_205951");
message.Attachments.Add((System.Net.Mail.Attachment)attachment);
Thanks
Emily FosterPosted Mar 17, 2025, 6:02 AM
The error you are encountering - "Attachment is not null here" - typically occurs when there is a mismatch between the attachment types being handled.
In your provided code snippet, you are trying to add an attachment of type `SAPbobsCOM.Attachment` to an email message, which expects `System.Net.Mail.Attachment`.
To rectify this issue, you need to convert the `SAPbobsCOM.Attachment` to `System.Net.Mail.Attachment` before adding it to the email message. Here's how you can achieve this:
By making this adjustment, you ensure that the attachment added to the email message is of the correct type, resolving the "Attachment is not null here" error.
If you need further assistance or clarification, feel free to ask.