using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.Mail; using System.Reflection; using Quiksoft.FreeSMTP; namespace glorija { /// /// Summary description for WebForm1. /// public class SendMail : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { sendMailBrinkster(); } private void sendMailBrinkster() { string mailTo = "info@glorija.net"; string maleFrom = "info@glorija.net"; string subject = "Info Glorija"; string body = null; // //mailTo = (Request["mailTo"]).ToString(); body = (Request["body"]).ToString(); //body = Server.UrlEncode(body); // Type AspEmailType = Type.GetTypeFromProgID("Persits.MailSender"); object AspEmailObject = Activator.CreateInstance(AspEmailType); object[] hostParam = new object[1]; object[] fromParam = new object[1]; object[] toParam = new object[1]; object[] usernameParam = new object[1]; object[] passwordParam = new object[1]; object[] subjectParam = new object[1]; object[] bodyParam = new object[1]; hostParam[0] = "sendmail.brinkster.com"; fromParam[0] = maleFrom; toParam[0] = mailTo; usernameParam[0] = "info@glorija.net"; passwordParam[0] = "1234glorija"; subjectParam[0] = subject; bodyParam[0] = body; AspEmailType.InvokeMember("Host", BindingFlags.SetProperty, null, AspEmailObject, hostParam); AspEmailType.InvokeMember("From", BindingFlags.SetProperty, null, AspEmailObject, fromParam); AspEmailType.InvokeMember("AddAddress", BindingFlags.InvokeMethod, null, AspEmailObject, toParam); AspEmailType.InvokeMember("Username", BindingFlags.SetProperty, null, AspEmailObject, usernameParam); AspEmailType.InvokeMember("Password", BindingFlags.SetProperty, null, AspEmailObject, passwordParam); AspEmailType.InvokeMember("Subject", BindingFlags.SetProperty, null, AspEmailObject, subjectParam); AspEmailType.InvokeMember("Body", BindingFlags.SetProperty, null, AspEmailObject, bodyParam); //AspEmailType.InvokeMember("Send", BindingFlags.InvokeMethod, null, AspEmailObject, null); try { AspEmailType.InvokeMember("Send", BindingFlags.InvokeMethod, null, AspEmailObject, null); Response.Write("Vaša poruka je uspješno poslana, hvala što ste me kontaktirali."); } catch (Exception) { Response.Write("Vaša poruka nije uspješno poslana, pokušajte ponovno."); } } private void sendMailBrinkster2() { string mailTo = "info@glorija.net"; string maleFrom = "info@glorija.net"; string subject = "Info Glorija"; string body = null; string helloMessage = null; string htmlBody = null; // body = (Request["body"]).ToString(); helloMessage = "Imate novu poruku sa vaše stranice:"; // htmlBody = "Info Glorija" + HttpUtility.HtmlEncode(helloMessage) + "

" + HttpUtility.HtmlEncode(body) + ""; // MailMessage oMessage = new MailMessage(); oMessage.BodyFormat = MailFormat.Html; oMessage.To = mailTo; oMessage.From = maleFrom; oMessage.Subject = subject; oMessage.Body = htmlBody; //oMessage.BodyEncoding = System.Text.Encoding.GetEncoding("windows-1250"); oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2; oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "sendmail.brinkster.com"; oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "info@glorija.net"; oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "1234glorija"; oMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1; System.Web.Mail.SmtpMail.SmtpServer = "mail.glorija.net"; Response.Write("Šaljem"); try { System.Web.Mail.SmtpMail.Send(oMessage); Response.Write("Vaša poruka je uspješno poslana, hvala što ste me kontaktirali."); } catch (Exception) { Response.Write("Vaša poruka nije uspješno poslana, pokušajte ponovno."); } } private void sendMailFreeSMTP() { string htmlBody = null; string body = null; string helloMessage = null; body = (Request["body"]).ToString(); helloMessage = "Imate novu poruku sa vaše stranice:"; htmlBody = "Info Glorija" + HttpUtility.HtmlEncode(helloMessage) + "

" + HttpUtility.HtmlEncode(body) + ""; //Create the EmailMessage object EmailMessage msgObj = new EmailMessage(); //Specify from address and display name msgObj.From.Email="sinfo@glorija.net"; msgObj.From.Name="Info Glorija"; //Add a normal recipient //msgObj.Recipients.Add("recipient@domain.com", "Recipient Name", RecipientType.To); //Specify the subject msgObj.Subject="Info Glorija"; // //msgObj.CharsetEncoding.GetEncoder //Add an HTML body part msgObj.BodyParts.Add(htmlBody, BodyPartFormat.HTML); //Add a text body part to server as alternative text for non HTML mail readers msgObj.BodyParts.Add(body, BodyPartFormat.Plain); //Add an attachment //msgObj.Attachments.Add("c:\\attachment.txt"); //Password //msgObj.BodyParts.Add(password,"1234glorija"); //Create the SMTP object using the constructor to specify the mail server SMTP smtpObj = new SMTP("sendmail.brinkster.com"); //Send the message smtpObj.Send(msgObj); } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { } #endregion } // // }