my requirement is how to implement mail merge using Database in C# (MVC)
Hello,
Our documentation is available at api.onlyoffice.com
ONLYOFFICE Api Documentation - Config
ONLYOFFICE Api Documentation - Methods
Hello carl,
I am able to test mail merge functionality using “csv” file now I want to test the same while fetching elements and data from database (SQL Database)/Static Data
The following code I am using for CSV file please help me to modify it for the Database/Static Data.
This code belongs to Editor.aspx page
private Dictionary<string, object> GetMailMergeConfig()
{
var mailmergeUrl = new UriBuilder(_Default.GetServerUrl(true));
mailmergeUrl.Path =
HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? “” : “/”)
+ “Handler1.ashx”;
mailmergeUrl.Query = “type=csv”;
Dictionary<string, object> mailMergeConfig = new Dictionary<string, object>
{
{ "fileType", "csv" },
{ "url", mailmergeUrl.ToString() }
};
if (JwtManager.Enabled)
{
var mailmergeToken = JwtManager.Encode(mailMergeConfig);
mailMergeConfig.Add("token", mailmergeToken);
}
return mailMergeConfig;
}
This code belongs to Handler1.ashx page
private static void GetCsv(HttpContext context)
{
var fileName = “csv.csv”;
var filePath = HttpRuntime.AppDomainAppPath + “Default/” + fileName;
download(filePath, context);
}
private static void download(string filePath, HttpContext context)
{
FileInfo fileinf = new FileInfo(filePath);
context.Response.AddHeader(“Content-Length”, “” + fileinf.Length);
context.Response.AddHeader(“Content-Type”, MimeMapping.GetMimeMapping(filePath));
var tmp = HttpUtility.UrlEncode(Path.GetFileName(filePath));
tmp = tmp.Replace("+", “%20”);
context.Response.AddHeader(“Content-Disposition”, “attachment; filename*=UTF-8’’” + tmp);
context.Response.TransmitFile(filePath);
}
Hello,
We can not assess your code.
As for this, it is not possible. Recipient data must be provided as a file.