Hi There,
I use follow code to send email inside VB.NET 2005. It does not work well.
Error message of "Failure sending email" would occue. However, email was
sent out sometimes. I am confused and please help.
Thanks in advance.
Hugh
Imports System.net.Mail
Public Class Form1
Sub SendEmail(ByVal strFrom As String, ByVal strTo _
As String, ByVal strSubject As String, ByVal strMessage _
As String, ByVal file As String)
Try
Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New
MailAddress(strTo))
MailMsg.Subject = strSubject.Trim()
MailMsg.Body = strMessage.Trim() & vbCrLf
MailMsg.Priority = MailPriority.High
MailMsg.IsBodyHtml = True
If Not file = "" Then
Dim MsgAttach As New Attachment(file)
MailMsg.Attachments.Add(MsgAttach)
End If
'Smtpclient to send the mail message
Dim SmtpMail As New SmtpClient
SmtpMail.Host = "10.10.10.10"
SmtpMail.Send(MailMsg)
Catch ex As Exception
MessageBox.Show(ex.Message & " in SendEmail")
End Try
End Sub
Sub SendOneEmail()
Dim SendFrom, SendTo, Attach, strSubject, strMessage As String
Try
SendFrom = "ab***@yahoo.com"
SendTo = “fg***@yahoo.com”
Attach = "c:\text.txt"
strSubject = “Email Subject”
strMessage = “Email Body. This is a test”
SendEmail(SendFrom, SendTo, strSubject, strMessage, Attach)
Catch ex As Exception
MessageBox.Show(ex.Message & "in SendOneEmail")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SendOneEmail()
End Sub
End Class 3 9612
On Feb 15, 11:08 am, Hugh <H...@discussions.microsoft.comwrote:
Hi There,
I use follow code to send email inside VB.NET 2005. It does not work well.
Error message of "Failure sending email" would occue. However, email was
sent out sometimes. I am confused and please help.
Thanks in advance.
Hugh
Imports System.net.Mail
Public Class Form1
Sub SendEmail(ByVal strFrom As String, ByVal strTo _
As String, ByVal strSubject As String, ByVal strMessage _
As String, ByVal file As String)
Try
Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New
MailAddress(strTo))
MailMsg.Subject = strSubject.Trim()
MailMsg.Body = strMessage.Trim() & vbCrLf
MailMsg.Priority = MailPriority.High
MailMsg.IsBodyHtml = True
If Not file = "" Then
Dim MsgAttach As New Attachment(file)
MailMsg.Attachments.Add(MsgAttach)
End If
'Smtpclient to send the mail message
Dim SmtpMail As New SmtpClient
SmtpMail.Host = "10.10.10.10"
SmtpMail.Send(MailMsg)
Catch ex As Exception
MessageBox.Show(ex.Message & " in SendEmail")
End Try
End Sub
Sub SendOneEmail()
Dim SendFrom, SendTo, Attach, strSubject, strMessage As String
Try
SendFrom = "a...@yahoo.com"
SendTo = "f...@yahoo.com"
Attach = "c:\text.txt"
strSubject = "Email Subject"
strMessage = "Email Body. This is a test"
SendEmail(SendFrom, SendTo, strSubject, strMessage, Attach)
Catch ex As Exception
MessageBox.Show(ex.Message & "in SendOneEmail")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SendOneEmail()
End Sub
End Class
Is the .txt file in use when you try to send the email?
Hi Izzy,
I am not sure what you asked. I assume that you meant attachment file.
Yes, attachment was sent in the email. I did find the attachment in the
email that were able to sent out.
"Izzy" wrote:
On Feb 15, 11:08 am, Hugh <H...@discussions.microsoft.comwrote:
Hi There,
I use follow code to send email inside VB.NET 2005. It does not work well.
Error message of "Failure sending email" would occue. However, email was
sent out sometimes. I am confused and please help.
Thanks in advance.
Hugh
Imports System.net.Mail
Public Class Form1
Sub SendEmail(ByVal strFrom As String, ByVal strTo _
As String, ByVal strSubject As String, ByVal strMessage _
As String, ByVal file As String)
Try
Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New
MailAddress(strTo))
MailMsg.Subject = strSubject.Trim()
MailMsg.Body = strMessage.Trim() & vbCrLf
MailMsg.Priority = MailPriority.High
MailMsg.IsBodyHtml = True
If Not file = "" Then
Dim MsgAttach As New Attachment(file)
MailMsg.Attachments.Add(MsgAttach)
End If
'Smtpclient to send the mail message
Dim SmtpMail As New SmtpClient
SmtpMail.Host = "10.10.10.10"
SmtpMail.Send(MailMsg)
Catch ex As Exception
MessageBox.Show(ex.Message & " in SendEmail")
End Try
End Sub
Sub SendOneEmail()
Dim SendFrom, SendTo, Attach, strSubject, strMessage As String
Try
SendFrom = "a...@yahoo.com"
SendTo = "f...@yahoo.com"
Attach = "c:\text.txt"
strSubject = "Email Subject"
strMessage = "Email Body. This is a test"
SendEmail(SendFrom, SendTo, strSubject, strMessage, Attach)
Catch ex As Exception
MessageBox.Show(ex.Message & "in SendOneEmail")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SendOneEmail()
End Sub
End Class
Is the .txt file in use when you try to send the email?
On Feb 15, 11:56 am, Hugh <H...@discussions.microsoft.comwrote:
Hi Izzy,
I am not sure what you asked. I assume that you meant attachment file.
Yes, attachment was sent in the email. I did find the attachment in the
email that were able to sent out.
"Izzy" wrote:
On Feb 15, 11:08 am, Hugh <H...@discussions.microsoft.comwrote:
Hi There,
I use follow code to send email inside VB.NET 2005. It does not work well.
Error message of "Failure sending email" would occue. However, email was
sent out sometimes. I am confused and please help.
Thanks in advance.
Hugh
Imports System.net.Mail
Public Class Form1
Sub SendEmail(ByVal strFrom As String, ByVal strTo _
As String, ByVal strSubject As String, ByVal strMessage _
As String, ByVal file As String)
Try
Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New
MailAddress(strTo))
MailMsg.Subject = strSubject.Trim()
MailMsg.Body = strMessage.Trim() & vbCrLf
MailMsg.Priority = MailPriority.High
MailMsg.IsBodyHtml = True
If Not file = "" Then
Dim MsgAttach As New Attachment(file)
MailMsg.Attachments.Add(MsgAttach)
End If
'Smtpclient to send the mail message
Dim SmtpMail As New SmtpClient
SmtpMail.Host = "10.10.10.10"
SmtpMail.Send(MailMsg)
Catch ex As Exception
MessageBox.Show(ex.Message & " in SendEmail")
End Try
End Sub
Sub SendOneEmail()
Dim SendFrom, SendTo, Attach, strSubject, strMessage As String
Try
SendFrom = "a...@yahoo.com"
SendTo = "f...@yahoo.com"
Attach = "c:\text.txt"
strSubject = "Email Subject"
strMessage = "Email Body. This is a test"
SendEmail(SendFrom, SendTo, strSubject, strMessage, Attach)
Catch ex As Exception
MessageBox.Show(ex.Message & "in SendOneEmail")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SendOneEmail()
End Sub
End Class
Is the .txt file in use when you try to send the email?- Hide quoted text -
- Show quoted text -
What I'm saying is....if this code works sometimes and not others,
that might be because the attachment file "whatever.txt" might be in
use by another process when you attempt to send the email.
Is there another process which creates this attachment file? If so it
might not be releasing it quick enough. I've run into this problem
before when creating .pdf files. My solution was to check the creation
date of the file and only use files older then 10 seconds, 5 might
even be ok. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jas |
last post by:
I have a basic client/server socket situation setup....where the server
accepts a connection and then waits for commands.
On the client side, I create a socket, connect to the server...then I...
|
by: lkrubner |
last post by:
Hi. I'm messing around with some stuff in an .htaccess file. Among
other things, I'd like to send my html files to the PHP parser. I'd
also like to rewrite the urls using Apache mod_rewrite, so...
|
by: JIM.H. |
last post by:
Hello,
I am using SmtpMail.Send() and I get the following message
The server rejected one or more recipient addresses. The server response
was: 550 5.7.1 Unable to relay for myMail@hotmail.com...
|
by: Andy G |
last post by:
Hi,
My plan is to use Try Catch statements to catch an error and then email it
to myself. I send the user to a custom error page and I would like to email
myself the asp.net error. I thought...
|
by: Traveller |
last post by:
Hi All ,
I am hoping some can help or point me in the right direction. We have
recenlty installed SQL 2005 and are using integrated services using ole
db connections. We are connecting to an...
|
by: Mike TI |
last post by:
April 12, 2006
Hi all
I want to send an email through a VB.Net 2005 application. Can someone show
me some examples:
1. To send an email through the current default email client, Outlook...
|
by: sentiboy |
last post by:
I am using the following code for sending email through mapi in VS 2005
environment:
Public objSession As New MSMAPI.MAPISession
Public objMessage As New MSMAPI.MAPIMessages
...
|
by: Tony M |
last post by:
VS 2005 - XP media - VB .net - winforms - .net 2.0
Just trying to send an email, here is the code and the error message that I
get. I can't figure out how to fix it?
|
by: Ed Bitzer |
last post by:
Trying to send groups of email with program using System.Net.Mail. I
do not clear MailMessage but repeatedly loop changing only the Bcc
entries. Works fine if all addresses are valid. As a simple...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
| |