2013-12-11 5 views
-1

VB.net에서 여러 전자 메일 주소로 텍스트 파일 첨부 파일을 보내 전자 메일을 자동화하는 문제가 있습니다. 이상한 부분은 우리가 2 명에게 메일을 보내면 첫 번째 사람은 이메일을 받지만 두 번째 사람은받지 못한다는 것입니다. 3 개의 이메일 주소를 추가하면 첫 번째 두 개의 이메일 주소로 이메일이 수신되지만 세 번째 이메일 주소에는 수신되지 않습니다. 이메일 주소를 추가 할 때이 방법으로 계속 진행됩니다. 또한 스크립트를 두 번 실행하는 동안 전자 메일은 모든 수신자에게 전달됩니다. 정확히 말하면 스크립트를 대체 실행 한 모든 수신자가 전자 메일을 수신합니다. 메일 서버 등의 시간과 관련이 있습니까? 마지막으로 작업을 수행하기 위해 마지막 전자 메일 주소에 대한 전자 메일 보내기 명령을 두 번 실행합니다. 나는 이것이 영구적 인 해결책이 아니라는 것을 알고있다. 도움을 주시면 감사하겠습니다. 미리 감사드립니다. 마지막 전자 메일 주소로 여러 전자 메일을 보내지 못했습니다.

public void Main() 
    { 
     SmtpClient client = new SmtpClient("1.1.1.1", 25); 

     client.DeliveryMethod = SmtpDeliveryMethod.Network; 

     client.Credentials = new NetworkCredential("support", "support"); 

     MailMessage EM1= new MailMessage("[email protected]", "[email protected] ", 
      "This is my subject" + " " + " ", "Hello,"); 

     EM1.Attachments.Add(new Attachment(@"F:\WebData\TxtFiles\1.txt")); 
     client.Send(EM1); 

     Dts.TaskResult = (int)ScriptResults.Success; 


     MailMessage EM2 = new MailMessage("[email protected]", "[email protected]", 
      "This is my subject" + " " + " ", "Hello,"); 

     EM2.Attachments.Add(new Attachment(@"F:\WebData\TxtFiles\1.txt")); 
     client.Send(EM2); 

     Dts.TaskResult = (int)ScriptResults.Success; 

     MailMessage EM3 = new MailMessage("[email protected]", "[email protected]", 
     "This is my subject" + " " + " ", "Hello,"); 

     EM3.Attachments.Add(new Attachment(@"F:\WebData\TxtFiles\1.txt")); 
     client.Send(EM3); 
     client.Send(EM3); 

     Dts.TaskResult = (int)ScriptResults.Success; 

    } 
} 

}

+0

코드가 붙여졌습니다. – Isha

+0

VB.net 코드와 비슷합니다. VB.net과 VBScript는 다른 언어입니다. –

+0

지적 해 주셔서 감사합니다. 나는 이것 (프로젝트조차도)에 완전히 새로운 것이다. 이 코드는 동료가 작성했습니다. 이 태그를 다른 태그로 태그해야합니까? – Isha

답변

0

당신이 확인해야합니다 첫 번째 장소는 메일 서버의 로그입니다. 그들은 제출 된 메시지 (수락/거부, 다음 홉 배달 등)로 어떤 일이 일어나고 있는지 알려줄 것입니다.

그러나 여러 수신자에게 동일한 메시지를 여러 번 보내는 것은 좋지 않습니다. 그렇게하는 것이 메일 서버의 작업입니다. 모든 수신자에게 메시지를 한 번만 제출하십시오.

MailMessage EM = new MailMessage("[email protected]", _ 
    "[email protected],[email protected],[email protected]", _ 
    "This is my subject", "Hello,"); 

EM.Attachments.Add(new Attachment(@"F:\WebData\TxtFiles\1.txt")); 
client.Send(EM);

또는 다음과 같이 추가로받는 사람을 추가 : 당신은 쉼표로 구분 된 문자열로 모든 수신자를 지정할 수 있습니다 당신이 다른받는 사람에 대해 알 수있는받는 사람을 원하지 않는 경우

MailMessage EM = new MailMessage("[email protected]", _ 
    "[email protected]", "This is my subject", "Hello,"); 

EM.To.Add("[email protected]"); 
EM.To.Add("[email protected]"); 

EM.Attachments.Add(new Attachment(@"F:\WebData\TxtFiles\1.txt")); 
client.Send(EM);

것은의를 보내 메시지를 기본 수신자 (예 : 보낸 사람 주소)에 추가하고 숨은 참조 주소로 다른 수신자를 추가하십시오.

MailMessage EM = new MailMessage("[email protected]", _ 
    "[email protected]", "This is my subject", "Hello,"); 

EM.Bcc.Add("[email protected]"); 
EM.Bcc.Add("[email protected]"); 
EM.Bcc.Add("[email protected]"); 

EM.Attachments.Add(new Attachment(@"F:\WebData\TxtFiles\1.txt")); 
client.Send(EM);
관련 문제