Search code examples
crystal-reportsmass-emails

I need to send multiple users monthly invoices using crystal reports and logicity as auto emails


is there any way to send multiple emails of invoice reports using one crystal report.

I am facing the issue like i have to send multiple emails for each user.

Thanks in advance. Ajay


Solution

  • Well, i just (FIO) figured it out but generating reports and saving to local drive rather then sending emails to you which is time consumption.

    // cs file method.

      //0. Setting Up controller
                    OpsManagementController OM = new OpsManagementController();
    
                    //1. Getting Users List:
                    var result = OM.GetUsersforInvoice();
    
                    //2. Creating folder for Invoices:
                    string folderName = @"D:\Google Drive\MonthlyInvoices";
                    string fileName = ("Invoices_" + DateTime.Now.ToString("dd-MM-yyyy").ToString());
                    string pathString = System.IO.Path.Combine(folderName, fileName);
                    System.IO.Directory.CreateDirectory(pathString);
    
                    //3. Generating invoices by user name:
                    for (int i = 0; i < result.UserDetail.Count; i++)
                    {
                        var userId = result.UserDetail[i].UserID;
                        var userName = result.UserDetail[i].FullName;
                        userName = userName.Replace(@"C\O", "CO");
                        userName = userName.Replace(@"C/O", "CO");
    
                        report2.SetParameterValue("UserID", result.UserDetail[i].UserID);
                        report2.ExportToDisk(ExportFormatType.PortableDocFormat, "D:/Google Drive/MonthlyInvoices/" + fileName + "/" + userName + ".pdf");
                    }
    

    contact please, if you need help.