MailMerge save a data source in word|_rel|settings.xml.rels

Is it somehow possible to save the data source in the word|_rel|settings.xml.rels?
Because manually, I can save my attached data source in this location.

My goal is that when a user opens a docx file, that they can then automatically use the attached data source file in the mailings tab.

What I have tried so far:

const auto doc = System::MakeObject\<Aspose::Words::Document\>(u"C:\\dev\\aspose\\mailmerge.docx");
auto mailmergeSettings = doc->get_MailMergeSettings();
auto odsoObject = System::MakeObject\<Aspose::Words::Settings::Odso\>();
odsoObject->set_DataSource(u"C:\\dev\\aspose\\mailmerge.txt");
mailmergeSettings->set_Odso(odsoObject);
doc->Save(u"C:\\dev\\aspose\\mailmerge101.docx", Aspose::Words::SaveFormat::Docx);

After saving the file, sadly doesn’t keep the attachment.

@VErger You should also specify data source type and query string. Please see the code example provide here:
https://reference.aspose.com/words/net/aspose.words.settings/mailmergesettings/

Code is in C#, but I think there should not be problems with translation. Please let us know if you need more assistance.

Thank you very much for your reply.
The following Code example worked.

const System::String dataSourceName = u"C:\\dev\\aspose\\mailmerge.txt";
const System::String documentName = u"C:\\dev\\aspose\\mailmerge.docx";

const auto doc = System::MakeObject<Aspose::Words::Document>(documentName);

const auto settings = doc->get_MailMergeSettings();
settings->set_MainDocumentType(Aspose::Words::Settings::MailMergeMainDocumentType::MailingLabels);
settings->set_CheckErrors(Aspose::Words::Settings::MailMergeCheckErrors::Simulate);
settings->set_DataType(Aspose::Words::Settings::MailMergeDataType::TextFile);
settings->set_DataSource(dataSourceName);
settings->set_Query(u"SELECT * FROM " + settings->get_DataSource());
settings->set_LinkToQuery(true);
settings->set_ViewMergedData(true);

const auto odsoObject = System::MakeObject<Aspose::Words::Settings::Odso>();
odsoObject->set_DataSource(dataSourceName);
odsoObject->set_DataSourceType(Aspose::Words::Settings::OdsoDataSourceType::Text);
odsoObject->set_ColumnDelimiter(';');
odsoObject->set_FirstRowContainsColumnNames(true);
settings->set_Odso(odsoObject);
doc->set_MailMergeSettings(settings);

doc->Save(documentName, Aspose::Words::SaveFormat::Docx);

After opening the file, I get prompted about my attached data source.
That’s what I needed.

@VErger It is perfect that you managed to achieve what you need. Please feel free to ask in case of any further issues.