troubleshooting Question

Help with sending mail Attachment

Avatar of g7bmp
g7bmp asked on
.NET ProgrammingVisual Basic.NETEmail Servers
15 Comments1 Solution295 ViewsLast Modified:
I am using System.Net.Mail to send e-mail from my program this works fine until i attach a file. The email then gets binned? sent to admin with a message saying that the e-mail account does not exist. This only happens when i add an attachment. Also if i try to send a message outside if the company say to a goggle mail address  an error occurs   @@@Mailbox unavailable. The server response was: 5.7.1 Unable to relay for @@@@
All address go when sent via outlook.

Any help would be appreciated
ByVal recipient As String, ByVal subject As String, _
        ByVal body As String, Optional ByVal attachmentString As String = "")
        Dim fromAddress As New MailAddress(sender)
        Dim toAddress As New MailAddress(recipient)
        Dim message As New MailMessage(fromAddress, toAddress)
        Dim mailSender As SmtpClient
        ' Change the Smtp server name on the next line
        mailSender = New SmtpClient("sprintmail", 25)
        message.Subject = subject
        message.IsBodyHtml = False
        message.Body = body
        If Not attachmentString = "" Then
            Dim msgAttach As New Attachment(attachmentString)
        End If
        Catch ex As Exception
            MsgBox("Error sending mail")
        End Try
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros