STEP 1 - MUST define server valid path
you should apply a valid and EXISTING !! folder on the SERVER from where to get the attach file. Usually this is the Upload folder path.

you should get it that way :
string ValidServerPath = Server.MapPath(string.Empty) + @"\" + UPLOAD_FOLDER + @"\";

STEP 2 - Get the valid path for the attach file
supply the attach file name and concat it to that path, like that :
string validServerFilePath = ValidServerPath + sAttachedFileName;

STEP 3 - Set encoding - IMPORTANT !!
you have to set the mail encoding to handle all types of extentions (.doc, .txt, .jpg ...)
to do that, create the MailAttachment object like that :
MailAttachment fileAttachment = new MailAttachment(validServerFilePath, MailEncoding.UUEncode);

STEP 4 - Attach the file to the message
myMsg.Attachments.Add(fileAttachment);
posted on 2007-07-13 10:50  MainIsUsed  阅读(189)  评论(0编辑  收藏  举报