...

View Full Version : .NET Email Attachments



A1ien51
10-24-2003, 03:24 PM
The following is a portion of my code for attachments with my email....



Dim objAttach As MailAttachment
Dim strPath As String = ""
Dim postedFile = txtAttachment.PostedFile
Try
strPath = Path.GetFullPath(postedFile.FileName)
Catch
End Try
Try
objAttach = New MailAttachment(strPath)
msg.Attachments.Add(objAttach)
Catch
End Try


If I remove the catch statments, it errors out saying my attachents are invalid. If I put them on, the mail is sent without the attachment.....

Any clue what could be wrong? If you want to see the rest of the VB code just yell.

Eric

angiras
10-24-2003, 03:40 PM
if you look in the SDK (ms-help://MS.NETFrameworkSDKv1.1.EN/cpref/html/frlrfsystemwebmailmailmessageclasstopic.htm) ( ms-help://MS.NETFrameworkSDKv1.1.EN/cpref/html/frlrfsystemwebmailmailmessageclasstopic.htm ) all is written, how to add attacment to a mail

does you path is valid ?

Throw an exception to know it

Try
objAttach = New MailAttachment(strPath)
msg.Attachments.Add(objAttach)
Catch
Throw new Exception("Attachment Path = " + strPath)
End Try

A1ien51
10-24-2003, 09:48 PM
okay I used a file off of the server with the following code and it worked:



msg.Attachments.Add(New MailAttachment(Server.MapPath("SendMailTrial.aspx")))


So I need to figure out why it will not except the file off of my local harddrive,.....

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum