PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET Sending Email in VB 2005

Reply

Sending Email in VB 2005

 
Thread Tools Rate Thread
Old 14-03-2007, 05:53 AM   #1
Rico
Guest
 
Posts: n/a
Default Sending Email in VB 2005


Hello,

I have an application in VB 2003 that uses System.Web that creates and sends
an email. I'm trying to turn this application into a Windows Service in VB
2005 and have discovered that System.Web.Mail is replaced by
System.Net.Mail, but it seems the "To" property is read only now? How do I
set this property so I can actually send the email?

Any direction would be greatly appreciated.

Thanks!
Rick


  Reply With Quote
Old 14-03-2007, 03:43 PM   #2
tclancey
Guest
 
Posts: n/a
Default Re: Sending Email in VB 2005

Try

'// Setup the new message.

Dim Message As New MailMessage("To", "From", "Subject", "Message")

'// Set the server to receive the smtp, exchange server or remote smtp
server

Dim EmailClient As New SmtpClient("DNS or IP")

'// If authentication is require it's set here.

' Dim SMTPUserInfo As New System.Net.NetworkCredential("Username",
"Password")

'// Defined by the above process, but doesn't seem to make much difference
is authentication is not required.

EmailClient.UseDefaultCredentials = False

'// If UserInfo is required this also need to be un-remmed

' EmailClient.Credentials = SMTPUserInfo

'// Send the Email!

EmailClient.Send(Message)

'// And confirm!

MsgBox("Done!")


"Rico" <me@you.com> wrote in message news:s5MJh.41851$lY6.37874@edtnps90...
> Hello,
>
> I have an application in VB 2003 that uses System.Web that creates and
> sends an email. I'm trying to turn this application into a Windows
> Service in VB 2005 and have discovered that System.Web.Mail is replaced by
> System.Net.Mail, but it seems the "To" property is read only now? How do
> I set this property so I can actually send the email?
>
> Any direction would be greatly appreciated.
>
> Thanks!
> Rick
>
>



  Reply With Quote
Old 17-03-2007, 01:52 PM   #3
Rico
Guest
 
Posts: n/a
Default Re: Sending Email in VB 2005

Hi tc,

Sorry for the delay in responding, I've been away for a while.

Thanks. I will give that a try.

Rick

"tclancey" <tull@idcodeware.co.uk> wrote in message
news:uUYWW%23kZHHA.4940@TK2MSFTNGP05.phx.gbl...
> Try
>
> '// Setup the new message.
>
> Dim Message As New MailMessage("To", "From", "Subject", "Message")
>
> '// Set the server to receive the smtp, exchange server or remote smtp
> server
>
> Dim EmailClient As New SmtpClient("DNS or IP")
>
> '// If authentication is require it's set here.
>
> ' Dim SMTPUserInfo As New System.Net.NetworkCredential("Username",
> "Password")
>
> '// Defined by the above process, but doesn't seem to make much difference
> is authentication is not required.
>
> EmailClient.UseDefaultCredentials = False
>
> '// If UserInfo is required this also need to be un-remmed
>
> ' EmailClient.Credentials = SMTPUserInfo
>
> '// Send the Email!
>
> EmailClient.Send(Message)
>
> '// And confirm!
>
> MsgBox("Done!")
>
>
> "Rico" <me@you.com> wrote in message
> news:s5MJh.41851$lY6.37874@edtnps90...
>> Hello,
>>
>> I have an application in VB 2003 that uses System.Web that creates and
>> sends an email. I'm trying to turn this application into a Windows
>> Service in VB 2005 and have discovered that System.Web.Mail is replaced
>> by System.Net.Mail, but it seems the "To" property is read only now? How
>> do I set this property so I can actually send the email?
>>
>> Any direction would be greatly appreciated.
>>
>> Thanks!
>> Rick
>>
>>

>
>



  Reply With Quote
Old 17-03-2007, 11:03 PM   #4
Rico
Guest
 
Posts: n/a
Default Re: Sending Email in VB 2005

Sweet! It works! Thanks TC!

"tclancey" <tull@idcodeware.co.uk> wrote in message
news:uUYWW%23kZHHA.4940@TK2MSFTNGP05.phx.gbl...
> Try
>
> '// Setup the new message.
>
> Dim Message As New MailMessage("To", "From", "Subject", "Message")
>
> '// Set the server to receive the smtp, exchange server or remote smtp
> server
>
> Dim EmailClient As New SmtpClient("DNS or IP")
>
> '// If authentication is require it's set here.
>
> ' Dim SMTPUserInfo As New System.Net.NetworkCredential("Username",
> "Password")
>
> '// Defined by the above process, but doesn't seem to make much difference
> is authentication is not required.
>
> EmailClient.UseDefaultCredentials = False
>
> '// If UserInfo is required this also need to be un-remmed
>
> ' EmailClient.Credentials = SMTPUserInfo
>
> '// Send the Email!
>
> EmailClient.Send(Message)
>
> '// And confirm!
>
> MsgBox("Done!")
>
>
> "Rico" <me@you.com> wrote in message
> news:s5MJh.41851$lY6.37874@edtnps90...
>> Hello,
>>
>> I have an application in VB 2003 that uses System.Web that creates and
>> sends an email. I'm trying to turn this application into a Windows
>> Service in VB 2005 and have discovered that System.Web.Mail is replaced
>> by System.Net.Mail, but it seems the "To" property is read only now? How
>> do I set this property so I can actually send the email?
>>
>> Any direction would be greatly appreciated.
>>
>> Thanks!
>> Rick
>>
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off