2017-12-15 3 views
1

Google Exchange 서버 제공 업체가 업데이트를했기 때문에 더 이상 이미지가 포함 된 이메일을 보낼 수 없습니다.Exchange 서버가 이미지가 포함 된 이메일을 차단합니다.

이메일을 보내 자마자 "원격 서버에서 (401) 권한이 없습니다."라는 오류 메시지가 나타납니다. 이메일에서 이미지를 삭제하면 모든 것이 올바르게 작동합니다. 이 문제의 해결 방법은 있습니까?

우리의 C# 코드 :

AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html"); 
LinkedResource imagelink; 
MatchCollection matches = Regex.Matches(Body, "<img.*?src=\"cid:(.*?)\""); 
foreach (Match match in matches) 
{ 
    myHttpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(match.Groups[1].Value)); 

    myHttpWebRequest.UseDefaultCredentials = true; 
    myHttpWebRequest.PreAuthenticate = true; 
    myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials; 

    using (myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse()) 
    { 
     receivedStream = myHttpWebResponse.GetResponseStream(); 

     MemoryStream streamReceivedCopy = new MemoryStream();      
     ImageUtils.CopyStream(receivedStream,streamReceivedCopy); 
     var imageType = ImageUtils.GetImageMIMEType(streamReceivedCopy); 
     streamReceivedCopy.Position = 0; 
     imagelink = new LinkedResource(streamReceivedCopy, imageType); 
     imagelink.ContentId = match.Groups[1].Value; 
     imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64; 
     htmlView.LinkedResources.Add(imagelink); 
    } 
} 
mail.AlternateViews.Add(htmlView); 

우리는 오류를 추적하기 위해 우리는 관리 이메일

답변

0

을 보내 다음의 .NET려면 SmtpClient를 사용 : 단지 오류의 원인이 전개되고 오래된 도서관이었다. 오래된 라이브러리에 다음 코드 줄이 누락되었습니다.

myHttpWebRequest.UseDefaultCredentials = true; 
myHttpWebRequest.PreAuthenticate = true; 
myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials; 

죄송합니다. :(

관련 문제