g7bmp
asked on
Help with sending mail Attachment
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
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.Bcc.Add(fromAddress)
message.Subject = subject
message.IsBodyHtml = False
message.Body = body
If Not attachmentString = "" Then
Dim msgAttach As New Attachment(attachmentString)
message.Attachments.Add(msgAttach)
End If
Try
mailSender.Send(message)
Catch ex As Exception
MsgBox("Error sending mail")
End Try
ASKER
I have just tried this and get loads of errors Attaching the file is not the problem though. It does attach but does not then send the mail to the recipient. says it is not a valid address. This only happens when there is a file attached.
What error do you get ?
ASKER
As below
The account does exist and will go if there is no file attched
The following recipient(s) could not be reached:
The e-mail account does not exist at the organization this message was sent to. Check the e-mail address, or contact the recipient directly to find out the correct address.
SprintMail.Sprint.local
Control on 28/05/2008 17:00
The e-mail account does not exist at the organization this message was sent to. Check the e-mail address, or contact the recipient directly to find out the correct address.
SprintMail.Sprint.local
The account does exist and will go if there is no file attched
The following recipient(s) could not be reached:
The e-mail account does not exist at the organization this message was sent to. Check the e-mail address, or contact the recipient directly to find out the correct address.
SprintMail.Sprint.local
Control on 28/05/2008 17:00
The e-mail account does not exist at the organization this message was sent to. Check the e-mail address, or contact the recipient directly to find out the correct address.
SprintMail.Sprint.local
your server surely blocks relay. see http://www.systemnetmail.com/
ASKER
Would not this block all mail not just the ones with attchments
I was targetting your "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 @@@@"
ASKER
Oh ok thank for that but still have this attachment issue
ASKER
Still in need of help please
is it possible that there are rules on the server that block some attachment? talk to your sysadmin.
ASKER
Hi
There are no rules on the system that block attacments and i have just found out that it will not send to another domain ie google. think it is an exchange problem but do not know what. as i can send from outlook
There are no rules on the system that block attacments and i have just found out that it will not send to another domain ie google. think it is an exchange problem but do not know what. as i can send from outlook
>>it will not send to another domain
Back to sqare one. Relay is blocked. See http://www.systemnetmail.com/faq/1.4.aspx
Back to sqare one. Relay is blocked. See http://www.systemnetmail.com/faq/1.4.aspx
ASKER
All computers on the domain are allowed to relay mail
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Used google SMTP works fine thanks
Dim data As New Attachment(file, MediaTypeNames.Application
' Add time stamp information for the file.
Dim disposition As ContentDisposition = data.ContentDisposition
disposition.CreationDate = System.IO.File.GetCreation
disposition.ModificationDa
disposition.ReadDate = System.IO.File.GetLastAcce
' Add the file attachment to this e-mail message.
message.Attachments.Add(da