private bool MakeNotification(Core.Notifications NObj) { try { var M = new Core.Tools.Mail(); var ms = new MemoryStream(); var ListAtt = new List <Attachment>(); var FileName = string.Format("Notification_{0:yyyy-MM-dd}_{1}.pdf", DateTime.Now, Guid.NewGuid().ToString().Substring(1, 6)); switch (hfNotifyType.Value) { case "2": var rpt2 = new rptNotifForm1(NObj); rpt2.ExportToPdf(ms); break; case "3": var rpt3 = new rptNotifForm2(NObj); rpt3.ExportToPdf(ms); break; case "4": var rpt4 = new rptNotifForm3(NObj); rpt4.ExportToPdf(ms); break; } ms.Seek(0, System.IO.SeekOrigin.Begin); var attach = new Attachment(ms, FileName, "application/pdf"); ListAtt.Add(attach); M.Send("*****@*****.**", "*****@*****.**", "სანოტიიკაციო ფორმა", "ინფორმაცია საიტიდან", AttachmentsList: ListAtt); ms.Close(); return(true); } catch (Exception ex) { return(false); } }
protected void btnSend_Click(object sender, EventArgs e) { var N = new NoficicationsRepository(); var fuURLFileName = ""; if (fuURL.HasFile) { fuURLFileName = fuURL.FileName.ToAZ09Dash(true, true); var path = string.Format("{0}//Notifications//", Utility.GetUploadFolder()); fuURL.SaveAs(string.Format("{0}{1}", path, fuURLFileName)); } var NotifType = new DictionariesRepository().ListDictionary(1, 9).FirstOrDefault(w => w.CodeVal == 1).DictionaryID; var BDate = new DateTime(Convert.ToInt32(ddBYear.SelectedValue), Convert.ToInt32(ddBMonth.SelectedValue), Convert.ToInt32(ddBDay.SelectedValue)); var EnteryDate = string.IsNullOrEmpty(txtFDate.Text) ? DateTime.Now : DateTime.Parse(txtFDate.Text); var LeaveDate = string.IsNullOrEmpty(txtLDate.Text) ? DateTime.Now : DateTime.Parse(txtLDate.Text); /* * N.SP_Notifications(0, * NotificationTypeID: NotifType, * URL: fuURLFileName, * FName: txtFName.Text, * LName: txtLName.Text, * Address: txtAddress.Text, * Mobile: txtMobile.Text, * Fax: txtFax.Text, * Email: txtEmail.Text, * PassportN: txtPassportN.Text, * Nationality: txtNationality.Text, * BDate: BDate, * Gender: bool.Parse(ddGender.SelectedValue), * EnteryDate: EnteryDate, * LeaveDate: LeaveDate, * Organisator: ddOrganisator.SelectedValue, * TransportType: ddTransportType.SelectedValue, * Destination: txtDestination.Text, * HostName: txtHostName.Text, * HostContact: txtHostContact.Text, * EmFName : txtFName1.Text, * EmLName: txtLName1.Text, * EmAddress: txtAddress1.Text, * EmMobile: txtMobile1.Text, * VisitorStatus : txtProjectStatus.Text, * ProjectTitle: txtProjectName.Text, * ProjectNote :txtProjectGoal.Text, * ProjectFDate: DateTime.Parse(txtProjectFDate.Text), * ProjectLDate:DateTime.Parse(txtProjectLDate.Text), * Partner: txtLocalPartner.Text, * IsSent : bool.Parse(ddIsSent.SelectedValue), * Note: txtNote.Text); * if (!N.IsError) * { */ var NotifyObject = new Core.Notifications { NotificationTypeID = NotifType, URL = fuURLFileName, FName = txtFName.Text, LName = txtLName.Text, Address = txtAddress.Text, Mobile = txtMobile.Text, Fax = txtFax.Text, Email = txtEmail.Text, PassportN = txtPassportN.Text, Nationality = txtNationality.Text, BDate = BDate, //Sex = bool.Parse(ddGender.SelectedValue), EnteryDate = EnteryDate, LeaveDate = LeaveDate, Organisator = txtVisitOrganisedBy.Text, TransportType = ddTransportType.SelectedValue, Destination = txtDestination.Text, HostName = txtHostName.Text, HostContact = txtHostContact.Text, EmFName = txtFName1.Text, EmLName = txtLName1.Text, EmAddress = txtAddress1.Text, EmMobile = txtMobile1.Text, VisitorStatus = txtProjectStatus.Text, ProjectTitle = txtProjectName.Text, ProjectNote = txtProjectGoal.Text, ProjectFDate = DateTime.Parse(txtProjectFDate.Text), ProjectLDate = DateTime.Parse(txtProjectLDate.Text), Partner = txtLocalPartner.Text, //IsSent = bool.Parse(ddIsSent.SelectedValue), Note = txtNote.Text }; var M = new Core.Tools.Mail(); var ms = new MemoryStream(); var ListAtt = new List <Attachment>(); var rpt = new rptNotification(NotifyObject); var FileName = string.Format("Notification_{0:yyyy-MM-dd}_{1}.pdf", DateTime.Now, Guid.NewGuid().ToString().Substring(1, 6)); rpt.ExportToPdf(ms); ms.Seek(0, System.IO.SeekOrigin.Begin); var attach = new Attachment(ms, FileName, "application/pdf"); ListAtt.Add(attach); M.Send("*****@*****.**", "*****@*****.**", "სანოტიფიკაციო ფორმა", "ინფორმაცია საიტიდან", AttachmentsList: ListAtt); ms.Close(); Session["IsSent"] = true; Response.Redirect(Request.Url.OriginalString); //} }