Send mail
-
I am unable to send mail using CDOSYS. My code is as follows: - MailMessage msgPsw = new MailMessage(); string strBody = "How r u"; msgPsw.To = "abc@yahoo.com"; msgPsw.From = "aasstt@vsnl.com"; msgPsw.Cc = strDbMailID; msgPsw.Subject = "Hi"; msgPsw.Body = strBody; msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtserver", "server IP address"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendserverport", "25"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); try { SmtpMail.Send(msgPsw); } catch(System.Web.HttpException ehttp) { string strError = ehttp.Message + "" + ehttp.ToString(); LabelErr.Text = strError ; } Can somebody please help me aasstt
-
I am unable to send mail using CDOSYS. My code is as follows: - MailMessage msgPsw = new MailMessage(); string strBody = "How r u"; msgPsw.To = "abc@yahoo.com"; msgPsw.From = "aasstt@vsnl.com"; msgPsw.Cc = strDbMailID; msgPsw.Subject = "Hi"; msgPsw.Body = strBody; msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtserver", "server IP address"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendserverport", "25"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); try { SmtpMail.Send(msgPsw); } catch(System.Web.HttpException ehttp) { string strError = ehttp.Message + "" + ehttp.ToString(); LabelErr.Text = strError ; } Can somebody please help me aasstt
Here's some vb 2005 code that works
Dim smtpMail As New System.Net.Mail.SmtpClient Dim emlMessage As New System.Net.Mail.MailMessage() With emlMessage .From = New System.Net.Mail.MailAddress(emailAddressTextBox.Text, nameTextBox.Text) .Subject = subjectTextBox.Text .Body = messageTextBox.Text .To.Add(emailAddressTextBox.Text) 'you can add as many email addresses as required .IsBodyHtml = False End With With smtpMail .Host = "smtp.domain.com" .DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network .Credentials = New System.Net.NetworkCredential("SmtpServerLogonName", "Password") .Send(emlMessage) End With
Steve Jowett
-
I am unable to send mail using CDOSYS. My code is as follows: - MailMessage msgPsw = new MailMessage(); string strBody = "How r u"; msgPsw.To = "abc@yahoo.com"; msgPsw.From = "aasstt@vsnl.com"; msgPsw.Cc = strDbMailID; msgPsw.Subject = "Hi"; msgPsw.Body = strBody; msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtserver", "server IP address"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendserverport", "25"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); msgPsw.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); try { SmtpMail.Send(msgPsw); } catch(System.Web.HttpException ehttp) { string strError = ehttp.Message + "" + ehttp.ToString(); LabelErr.Text = strError ; } Can somebody please help me aasstt
Do you have installed the Virtual Mail Service in your Server? These code is at C# language, and use the localhost (IIS) mail Service.
private void SendEmailToClient(string to, string bodyMessage) { // System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0 // System.Net.Mail.SmtpClient is the alternate class for this in 2.0 SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try { MailAddress fromAddress = new MailAddress("YOUR EMAIL", "YOUR NAME"); // You can specify the host name or ipaddress of your server // Default in IIS will be localhost smtpClient.Host = "localhost"; //Default port will be 25 smtpClient.Port = 25; //From address will be given as a MailAddress Object message.From = fromAddress; MailAddress toAddress = new MailAddress(to); // To address collection of MailAddress message.To.Add(toAddress); message.Subject = "This is an Email Test"; // CC and BCC optional // MailAddressCollection class is used to send the email to various users // You can specify Address as new MailAddress message.CC.Add("admin@yoursite.com"); // You can specify Address directly as string message.Bcc.Add(new MailAddress("moraleso@fmmb.org")); //Body can be Html or text format //Specify true if it is html message message.IsBodyHtml = false; // Message body content message.Body = bodyMessage; // Send SMTP mail smtpClient.Send(message); //Send process was successful } catch (Exception ex) { Mensaje.Text = "You couldnt send the email" + ex.Message; } }
:)keep Learning and you never will be out of date...