2011-11-17 3 views
0

웹 사이트의 폴더 중 하나에서 단어 파일을 첨부하려고합니다.폴더에서 단어 문서 첨부, C# 메일 메시지

Attachment attachment = new Attachment(msg.Attachments.Add(HttpContext.Current.Server.MapPath(@"Docs\" + companyName + ".doc"))); 

내가 무엇입니까 이러한 오류 :

The best overloaded method match for 'System.Collections.ObjectModel.Collection<System.Net.Mail.Attachment>.Add(System.Net.Mail.Attachment)' has some invalid arguments 
cannot convert from 'void' to 'string' 
cannot convert from 'string' to 'System.Net.Mail.Attachment' 

어떤 생각 나는이 문제를 해결 할 수있는 방법을 이것은 내가 노력하고 어떻게? 사전에 감사합니다, Laziale의

답변

0
string path = HttpContext.Current.Server.MapPath(@"Docs\" + companyName + ".doc"); 
Attachment attachment = new Attachment(path); 
msg.Attachments.Add(attachment); 
0
Attachment a = new Attachment(HttpContext.Current.Server.MapPath(@"Docs\" + companyName + ".doc")); 
msg.Attachments.Add(a);