Results 1 to 3 of 3

Thread: send email attachment

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    138

    send email attachment

    Hi gurus
    I have the following code that put together with all your help, It works fine sending email but once I want to send an attachment it just dont do it, no error is given,the application does not crash, just the email with the attachment not been sent or at least not been getting by the account.

    as you can see I am using sbcglobal to send my emails

    Thanks for any help gurus

    Code:
    Dim filetosend As New System.Web.Mail.MailAttachment("c:\file.txt")
    
            Try
                Dim emailaccount As New System.Web.Mail.MailMessage
                emailaccount.To = "[email protected]"
                emailaccount.From = "[email protected]"
                emailaccount.Body = " "
                emailaccount.Subject = "my attachment"
                emailaccount.Attachments.Add(filetosend)
                email.BodyFormat = Web.Mail.MailFormat.Text
                System.Web.Mail.SmtpMail.SmtpServer = "mail.sbcglobal.net"
                System.Web.Mail.SmtpMail.Send(emailaccount)
            Catch ex As Exception
                MsgBox(ex.Message)
    
            End Try

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: send email attachment

    Are you using .NET 1.x or a later version? If it's a later version then you should be using System.Net.Mail rather than System.Web.Mail.

    That said, if it works fine without attachments and you get no errors with an attachment then I'd suggest that there's nothing wrong with the code as far as it's being correct. I'd suggest that either the SMTP server is not allowing your attachment for some reason or else the firewall at the other end is snaffling it. Have you tried sending the same attachment from your own mail client to the same address? Does it get through?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    138

    Re: send email attachment

    J.

    Thanks a bunch, using 2003 Fw 1.1, I will give your suggestion a try, but using their client I know it works as I have done it many times, is when I use VB that I does not work.

    Thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width