2011-03-10 5 views
5

MailMessage class을 사용하여 SmtpClient 클래스를 사용하여 배달하기 위해 SMTP 서버에 전송되는 전자 메일 메시지를 구성하려고합니다. 전자 메일은 Exchange 서버를 통해 Outlook에 구성됩니다. 위의 구현과 관련하여 다음과 같은 의문점이있었습니다.MailMessage를 Exchange Server로 보내고 SMTP 서버로 보내는 것의 차이점

1) Exchange Server와 SMTP 서버의 차이점은 무엇입니까?

2) 내 경우 Outlook Express는 내 자격 증명을 사용하여 Exchange 서버에 구성됩니다. SMTP 메일 주소를 어떻게 찾을 수있어서 MailMessage 클래스를 구현할 수 있습니까?

3) 위의 구현 기술이 실행 가능하지 않은 경우 Exchange 서버를 기반으로하는 응용 프로그램을 통해 전자 메일을 보내는 아이디어가 있습니까?

Visual Studio 2008, 프레임 워크 3.5 SP1을 사용하여 C# 언어로 winforms 응용 프로그램에서 작업하고 있습니다. 제 의심을 분명히하는 데 도움주세요.

나는 다음과 같은 코드를 사용하고

편집 할 수 있습니다. 어떤 오류도 발생시키지 않으며 작동하지도 않습니다. 나는 보내고 자신에게 이메일 아무 소용이

public static void CreateMessageWithAttachment(string server) 
    { 
     // Specify the file to be attached and sent. 
     // This example assumes that a file named Data.xls exists in the 
     // current working directory. 
     string file = "data.xls"; 
     // Create a message and set up the recipients. 
     MailMessage message = new MailMessage(
      "[email protected]", 
      "[email protected]", 
      "Quarterly data report.", 
      "See the attached spreadsheet."); 

     // Create the file attachment for this e-mail message. 
     Attachment data = new Attachment(file, MediaTypeNames.Application.Octet); 
     // Add time stamp information for the file. 
     ContentDisposition disposition = data.ContentDisposition; 
     disposition.CreationDate = System.IO.File.GetCreationTime(file); 
     disposition.ModificationDate = System.IO.File.GetLastWriteTime(file); 
     disposition.ReadDate = System.IO.File.GetLastAccessTime(file); 
     // Add the file attachment to this e-mail message. 
     message.Attachments.Add(data); 

     //Send the message. 
     SmtpClient client = new SmtpClient(server); 
     // Add credentials if the SMTP server requires them. 
     client.Credentials = CredentialCache.DefaultNetworkCredentials; 

    try { 
      client.Send(message); 
     } 
     catch (Exception ex) { 
      Console.WriteLine("Exception caught in CreateMessageWithAttachment(): {0}", 
       ex.ToString());    
     } 

     data.Dispose(); 
    } 
+0

@Phoenix : contoso.com은 도메인 예입니다.그 전자 우편은 진짜가 아니다. 그들을 찌를 필요가 없습니다. – BoltClock

답변

5

1) Exchange Server 및 SMTP 서버의 차이점은 무엇에 BU하려고?

Exchange 서버에 더 많은 내용이 있습니다. 내 경우

2)

, 나의 전망은 내가은 MailMessage 클래스를 구현할 수 있어요 그래서 나는 SMTP 주소를 찾을 수 있습니까 내 credentials.How를 사용하여 Exchange 서버에 구성되어?

Outlook -> 도구 -> 계정 -> 계정 편집.

교환 서버와 동일한 주소입니다. 포트 25는 표준 SMTP 포트입니다. Exchange에서 인증이 필요할 수 있습니다.

3) 위의 구현 기술이 가능하지 않은 경우 교환 서버를 기반으로하는 응용 프로그램을 통해 전자 메일을 보내는 아이디어가 있습니까?

MailMessage을 사용할 수 없으므로 이 필요합니다. Exchange를 사용

예 : Getting a sent MailMessage into the "Sent Folder"

+0

빠른 답장을 보내 주셔서 감사합니다. 솔루션을 얻기 위해 사용하고있는 코드로 내 질문을 업데이트했습니다. 내 코드 – reggie

+0

에 오류가 있는지 알아보십시오. 1. 첨부 파일없이 시도한 적이 있습니까? 2. 올바른 서버 주소를 사용하고 있습니까? 3) 자격 증명을 수동으로 지정하여 시도한 적이 있습니까? – jgauffin

+0

모든 질문에 대한 대답은 '예'입니다. 그러나 예를 들어 나의 교환 서버 주소는 작동하지 않는 abcd.abc.company.com입니다. 이제 SMTP 포트 번호를 지정하기 위해 abcd.abc.company.com:25로 변경했습니다. 하지만 그뿐만 아니라 작동하지 않습니다. – reggie

2

SMTP는 프로토콜, 두 시스템 사이의 통신을 제어하는 ​​규칙의 집합입니다. 이 프로토콜은 메일 전송 규칙을 정의합니다.

SMTP 서버는이 프로토콜을 사용하여 메일을 보내는 구성 요소 (주로 소프트웨어)입니다.

MS Exchange는 SMTP를 사용하여 메일을 보내지 만 도메인의 사용자에 대해서는 사용자와 사서함도 관리합니다.

관련 문제