Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts

    .NET Email Attachments

    The following is a portion of my code for attachments with my email....

    PHP Code:
            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

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SDK

    if you look in the SDK ( 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
    Last edited by angiras; 10-24-2003 at 02:44 PM.

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    okay I used a file off of the server with the following code and it worked:

    PHP Code:
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •