Hi
Attachment does not contain a constructor that takes 1 arguments. I am writing thos code using sap b1 Sdk
C#
SAPbobsCOM.Attachment attachment = new SAPbobsCOM.Attachment(@"10.0.1.10\SAP_Attachments\Outgoing Payments_204673_20250314_205951");
message.Attachments.Add(attachment);Thanks

Eliana BlakeRank #1,595 · 993 reputationPosted Mar 15, 2025, 4:29 AM EDT
It seems like you are encountering an issue regarding the constructor for the Attachment class in SAP Business One SDK where you are trying to use a constructor that doesn't match the available constructors in the SDK.
The error "Attachment does not contain a constructor that takes 1 argument" typically means that the Attachment class does not have a constructor that accepts a single argument, in this case, a string representing the file path.
In your code snippet, you are attempting to create an Attachment object with a file path passed as an argument. However, to create an Attachment object in SAP Business One SDK, you may need to use the appropriate constructor.
To resolve this issue, you should check the available constructors for the Attachment class in the SDK documentation. Most likely, you need to provide required parameters like attachment type, file path, and potentially other parameters as per the SDK specifications.
Here's a hypothetical example to illustrate how you might create an Attachment object considering potential constructor variations:
SAPbobsCOM.Attachment attachment = new SAPbobsCOM.Attachment(); attachment.AbsEntry = 123; // Example attachment ID attachment.FileName = "Outgoing Payments_204673_20250314_205951"; attachment.Override = SAPbobsCOM.BoYesNoEnum.tNO; attachment.FileExtension = ".pdf"; attachment.AttachmentEntry = 456; // Example attachment entryBy aligning your Attachment object creation with the correct constructor and required properties based on the SDK documentation, you should be able to address the issue and proceed with adding attachments successfully.
If you encounter any further challenges or need additional guidance, feel free to provide more details, and I'll be happy to assist further!
Jignesh KumarRank #91 · 22.9K reputationPosted Mar 15, 2025, 5:50 AM EDT
Hello Ramco,
Please use this code to create object and assing attachement,
SAPbobsCOM.Attachments2 oAttachment = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2); oAttachment.Lines.SourcePath = @"\\10.0.1.10\SAP_Attachments"; oAttachment.Lines.FileName = "Outgoing Payments_204673_20250314_205951"; if (oAttachment.Add() != 0) { // Handle error string errorMsg; int errorCode; oCompany.GetLastError(out errorCode, out errorMsg); Console.WriteLine("Error: " + errorMsg); } else { Console.WriteLine("Attachment added successfully."); }