2012-04-30 5 views
0

ASP.NET/C#アプリケーション(mvc3)ではMailを送信できます。C#:個人メールとグループメールに電子メールを送信する(グループメールでは機能しません)

これは私がそのために使用しています関数です。

public static void SendEmail(string fromEmail, string fromName, string toEmail, string toName, string subject, string emailBody, bool isBodyHtml, string[] attachments, string emailServer, int portNumber, string loginName, string loginPassword) 
    { 
     // setup email header 
     System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(); 

     // Set the message sender 
     // sets the from address for this e-mail message. 
     mailMessage.From = new System.Net.Mail.MailAddress(fromEmail, fromName); 
     // Sets the address collection that contains the recipients of this e-mail message. 
     string[] toEmailList = toEmail.Split(','); 
     string[] toNameList = toName.Split(','); 
     for (int i = 0;i<toEmailList.Length;++i) 
     { 
      mailMessage.To.Add(new System.Net.Mail.MailAddress(toEmailList[i],toNameList[i])); 
     } 
     // mailMessage.To.(new System.Net.Mail.MailAddress(toEmail, toName)); 

     // sets the message subject. 
     mailMessage.Subject = subject; 
     // sets the message body. 
     mailMessage.Body = emailBody; 
     // sets a value indicating whether the mail message body is in Html. 
     // if this is false then ContentType of the Body content is "text/plain". 
     mailMessage.IsBodyHtml = isBodyHtml; 

     // add all the file attachments if we have any 
     if (attachments != null && attachments.Length > 0) 
      foreach (string _Attachment in attachments) 
       mailMessage.Attachments.Add(new System.Net.Mail.Attachment(_Attachment)); 

     // SmtpClient Class Allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP). 
     System.Net.Mail.SmtpClient _SmtpClient = new System.Net.Mail.SmtpClient(emailServer); 

     //Specifies how email messages are delivered. Here Email is sent through the network to an SMTP server. 
     _SmtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; 

     // Some SMTP server will require that you first authenticate against the server. 
     // Provides credentials for password-based authentication schemes such as basic, digest, NTLM, and Kerberos authentication. 
     System.Net.NetworkCredential _NetworkCredential = new System.Net.NetworkCredential(loginName, loginPassword); 
     _SmtpClient.UseDefaultCredentials = false; 

     _SmtpClient.Credentials = _NetworkCredential; 
     _SmtpClient.Port = portNumber; 
     //Let's send it 
     try 
     { 
      _SmtpClient.Send(mailMessage); 
      mailMessage.Dispose(); 
      _SmtpClient = null; 
     } 
     catch (Exception ex) 
     { 
      throw ex; 
     } 

    } 

すべてが個人的な電子メールのために正常に動作します。

メールにの1(私はこれを送っていた電子メール)は、グループメールであれば、それはそれに送信しません:

問題はこれです。

グループ別メールは、複数の連絡先が添付されたメールを意味し、誰かがそのメールにメールを送信すると、そのメールをすべて受信します。グループメールの

誰かが[email protected]に電子メールを送信する場合、すべての私の家族はそれを受け取ります。

個人のメールだけでなく、あらゆる種類のメールにどのように機能させることができますか?

ありがとうございました

答えて

0

私の個人的なGoogle Appsドメインで同じ問題がありました。しかし、問題はGroup Emailの設定であり、C#コードではありませんでした。

グループメールの権限を確認しましたか?多くの場合、このグループ電子メールに電子メールを送信できるユーザーを定義することができます。正しいメールアドレスを使用するか、権限を再設定する必要があります。通常、グループのすべてのメンバーはグループに電子メールを送信できます。

関連する問題