Send email to multiple recipient after file has been converted


hi,

in program, i'm converting files crystal reports .pdf dynamic names. each file associated 1 client. each client has own email address. have email address in database table (sql server).  i like, everytime there's new pdf has been created emails client attachement of pdf file.

this method convert files crystal pdf:

private void exportreport(string reportpath) { string filename = path.getfilename(reportpath); reportdocument report = new reportdocument(); report.load(reportpath); try { exportoptions options = report.exportoptions; options.exportdestinationtype = exportdestinationtype.diskfile; options.exportformattype = exportformattype.portabledocformat; options.destinationoptions = new diskfiledestinationoptions() { diskfilename = string.format( @"c:\users\test\desktop\convertedfiles\{0}_detailedcallreport_{1:yyyymm}.pdf", system.io.path.getfilenamewithoutextension(filename), datetime.now.addmonths(-1) ) }; options.formatoptions = new pdfrtfwordformatoptions(); report.export();

//send email email(); } catch (exception ex) { messagebox.show(ex.tostring()); } }

this how send email:

 private void email()          {                            try              {                  mailmessage mail = new mailmessage();                  smtpclient smtpserver = new smtpclient("smtp.gmail.com");                  mail.from = new mailaddress("myemail@gmail.com");                  mail.to.add("toperson@gmail.com");                  mail.subject = "detail call report";                  mail.body = "test";                    system.net.mail.attachment attachment;                  attachment = new system.net.mail.attachment("c:\\users\\test\\desktop\\test.pdf");                  mail.attachments.add(attachment);                    smtpserver.port = 587;                  smtpserver.credentials = new system.net.networkcredential("email", "password");                  smtpserver.enablessl = true;                    smtpserver.send(mail);                  label14.text = "message sent";              }              catch (exception ex)              {                  console.writeline(ex.tostring());              }          }


this email method not i'm looking for.

when call email(); method inside exportreport(); send email, 1 person specified attachement. not 1 getting generated.

i've tried replace line:

attachment = new system.net.mail.attachment("c:\\users\\test\\desktop\\test.pdf");


with this:

attachment = new system.net.mail.attachment(diskfilename);

to grab attachement, won't send email.

i've read threads here on how send email multiple recipients using database, did not work me.

any ideas on how can send emails different users with attachment that belongs them?

thank you. 


i not able complete in c#. however, wrote 2 stored procedures takes path of pdf files c# program , emails them out.


Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'