2012-03-21 27 views
-1
using System.Web; 
using System.Net.Mail; 
using System.Net; 

namespace hash 
{ 
    public partial class Form2 : Form 
    { 
     public Form2() 
     { 
      InitializeComponent(); 
     } 

     private void button1_Click(object sender, EventArgs e) 
     { 

      string toPhoneNumber = "DestinationPhoneNumber"; 
      string login = "id"; 
      string password = "pwd"; 
      string body = "Your Message"; 
      string To = toPhoneNumber + "@sms.ipipi.com"; 
      string From = login + "@ipipi.com"; 
      MailMessage mail = new MailMessage(From, To); 
      mail.Body = body; 
      SmtpClient smtp = new SmtpClient(); 
      SmtpClient client = new SmtpClient("ipipi.com",25); 
      smtp.Credentials = new NetworkCredential(login,password); 
      System.Security.Permissions.SecurityAction sa = new System.Security.Permissions.SecurityAction(); 
      SmtpPermissionAttribute smp = new SmtpPermissionAttribute(sa); 
      try{ 
       smtp.Send(mail); 
      } 
      catch (Exception ex) 
      { 
       MessageBox.Show(ex.Message); 
      } 
     } 
    } 
+0

イムは、plsはあなたが2 smtpclientsを作成している – nithyanandy

+1

を助ける指定されていなかった、目的は何ですか? SmtpClient smtp =新しいSmtpClient(); SmtpClientクライアント=新しいSmtpClient( "ipipi.com"、25); – daryal

答えて

4

てみ経由して携帯電話にSMSを送信しようとしている:

SmtpClient smtp = new SmtpClient("ipipi.com",25); 
//SmtpClient client = new SmtpClient("ipipi.com",25); 

希望@daryalは言及して...

+0

私は間違いを犯しました:(今もまた動作していません) – nithyanandy

+0

lol、同じエラー、別のエラー、エラーがありますか? – code4life

+0

考えてみたところです:ポート25がブロックされていないことを確認しましたか? – code4life

0

を支援2つの異なるクライアントを作成しています。それらを単一のクライアントにマージする必要があります。 SMTPホストとして例外を取得

SmtpClient smtp = new SmtpClient("ipipi.com",25); 
    smtp.Credentials = new NetworkCredential(login,password); 
    System.Security.Permissions.SecurityAction sa = new System.Security.Permissions.SecurityAction(); 
    SmtpPermissionAttribute smp = new SmtpPermissionAttribute(sa); 
    try{ 
     smtp.Send(mail); 
    } 
+0

ああ、私は間違いを犯しました:(今もまた動作していません) – nithyanandy

+0

私も例外を得ていません – nithyanandy

関連する問題