|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Send Email Using VB 2008 Expressto VB.NET and I am trying to learn what I can about this interesting technology. I found an example (online) of sending emails through .NET so I tried to follow the example and get this little app working...I’m really struggling here... I went to Control Panel > Add/Remove Programs > Add/Remove Windows Components > IIS > Details > SMTP (checked). I looked at this video: http://www.youtube.com/watch?v=VEi07SDbYg8&feature=related In the Video, the instructor is talking about System.Web.dll and System.Web.Mail, but I can’t find wither of these under my Project > Add References. I’m working with the same Form, as seen in the video, but my code is a little different because I couldn’t see some of the code that the Instructor was working with. I don’t think the problem is necessarily with the code; somehow I have to get the System.Web.dll…I think. Anyway, maybe it is the code. Here is what I’m working with: Imports System.Web Imports System.Web.Mail.SmtpMail.Send Public Class Form1 Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click Dim mail As New MailMessage() mail.To = txtTo.Text mail.From = txtFrom.Text mail.Subject = txtSubject.Text mail.Body = txtBody.Text SmtpMail.SmtpServer = "192.168.2.2" 'your real server goes here SmtpMail.Send(mail) MsgBox = ("Message Sent") Me.Close() End Sub End Class 192.168.2.2 is the IP of my laptop. When I hit the ‘Send’ button absolutely nothing happens. What am I doing worong? Thanks so much!! Ryan--- -- Ryan--- If this information was helpful, please indicate this by clicking ''Yes''. Rguy,
To use SMTP mail you have to activate that in the program and feature setting (in fact the features) Be aware that the web.mail version is deprecated, use this one instead http://msdn.microsoft.com/en-us/library/system.net.mail.aspx Be aware that you can use your local host (IP address 127.0.0.1) as a server or the mail.server from your provider, mostly those don't like that. But don't use a leased IP address on your computer from by instance the 192 range, this can be given by any router in a dynamic way. Cor Welcome to the party Cor. I think you’re right; I think it has something to
do with the SMTP. I’m still missing something here but I can’t tell what it is. Can you please walk me through the process, step by step? You said that I need to, ‘activate SMTP in the program and feature setting’. What does this mean? I did some research on this for about an hour today and made almost no progress on this. I guess ‘web.mail version is deprecated’. What does that mean? How do I give my 192.xxx IP address in a dynamic way? What do I click on? What are the steps? I have 5 .NET books, and none of them discuss the topic of sending emails via SMTP. I am delighted to be learning this stuff, but I seem to have hit a wall, and I don’t know what to do next. Any and all help is greatly appreciated. Ryan--- -- Show quoteHide quoteRyan--- If this information was helpful, please indicate this by clicking ''Yes''. "Cor Ligthert[MVP]" wrote: > Rguy, > > To use SMTP mail you have to activate that in the program and feature > setting (in fact the features) > > Be aware that the web.mail version is deprecated, use this one instead > > http://msdn.microsoft.com/en-us/library/system.net.mail.aspx > > Be aware that you can use your local host (IP address 127.0.0.1) as a server > or the mail.server from your provider, mostly those don't like that. > > But don't use a leased IP address on your computer from by instance the 192 > range, this can be given by any router in a dynamic way. > > Cor > > What OS are you using, on this page you see how to set the SMTP service for
XP prosional and things like that. http://www.emailarchitect.net/webapp/smtpcom/developers/smtpservice.asp Cor Show quoteHide quote "ryguy7272" <ryguy7***@discussions.microsoft.com> wrote in message news:20A3C817-BEB9-4E70-8670-AA98A87CDEB0@microsoft.com... > Welcome to the party Cor. I think you’re right; I think it has something > to > do with the SMTP. I’m still missing something here but I can’t tell what > it > is. Can you please walk me through the process, step by step? You said > that > I need to, ‘activate SMTP in the program and feature setting’. What does > this mean? I did some research on this for about an hour today and made > almost no progress on this. I guess ‘web.mail version is deprecated’. > What > does that mean? How do I give my 192.xxx IP address in a dynamic way? > What > do I click on? What are the steps? I have 5 .NET books, and none of them > discuss the topic of sending emails via SMTP. I am delighted to be > learning > this stuff, but I seem to have hit a wall, and I don’t know what to do > next. > > Any and all help is greatly appreciated. > Ryan--- > > > -- > Ryan--- > If this information was helpful, please indicate this by clicking ''Yes''. > > > "Cor Ligthert[MVP]" wrote: > >> Rguy, >> >> To use SMTP mail you have to activate that in the program and feature >> setting (in fact the features) >> >> Be aware that the web.mail version is deprecated, use this one instead >> >> http://msdn.microsoft.com/en-us/library/system.net.mail.aspx >> >> Be aware that you can use your local host (IP address 127.0.0.1) as a >> server >> or the mail.server from your provider, mostly those don't like that. >> >> But don't use a leased IP address on your computer from by instance the >> 192 >> range, this can be given by any router in a dynamic way. >> >> Cor >> >> Everyone, thank you soooo much for the help! I started this project 1 week
ago, and just finished today. As I alluded to before, I am a VBA guy, trying to become a VB.NET guy. Everyone's guidance was helpful, but in the end I just couldn't figure out how the SMTP server stuff worked, and that was the hangup for me. I eventually got help from a guy in my office. Thanks Sankalp!! So, anyway, I want to share the final product, so others can benefit from this experience. FYI, you need a Gmail account: Create a Form, and name it 'frmMain' Create a To TextBox, and name it 'txtTo' Create a CC TextBox, and name it 'txtCC' Create a BCC TextBox, and name it 'txtBCC' Create a Subject TextBox, and name it 'txtSubject' Create an email Body TextBox, and name it 'txtBody' Then, create a Send Button, and name it 'btnSend' This code goes under the Form: Imports System.Net.Mail Public Class frmMain Private _Username As String Private _Password As String Public Property UserName() As String Get Return _Username End Get Set(ByVal value As String) _Username = value End Set End Property Public Property Password() As String Get Return _Password End Get Set(ByVal value As String) _Password = value End Set End Property Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click 'Start by creating a mail message object Dim MyMailMessage As New MailMessage() 'From requires an instance of the MailAddress type Dim _from As String = UserName & "@gmail.com" MyMailMessage.From = New MailAddress(_from) 'To is a collection of MailAddress types If txtTo.Text <> "" Then MyMailMessage.To.Add(txtTo.Text) Else MessageBox.Show("You need to enter atlest one e-mail address") End If If txtBCC.Text <> "" Then MyMailMessage.Bcc.Add(txtBCC.Text) End If If txtCC.Text <> "" Then MyMailMessage.CC.Add(txtCC.Text) End If MyMailMessage.Subject = txtSubject.Text MyMailMessage.Body = txtBody.Text 'Create the SMTPClient object and specify the SMTP GMail server Dim SMTPServer As New SmtpClient("smtp.gmail.com") SMTPServer.Port = 587 ' SMTPServer.Credentials = New System.Net.NetworkCredential("sankalppande", "Bittu1541982") SMTPServer.Credentials = New System.Net.NetworkCredential(UserName, Password) SMTPServer.EnableSsl = True Try SMTPServer.Send(MyMailMessage) MessageBox.Show("Email Sent") Catch ex As SmtpException MessageBox.Show(ex.Message) End Try End Sub End Class Finally...yes, almost done... Create another Form, and name it 'LoginForm' Create a UserName TextBox and name it 'UsernameTextBox' Create a Password TextBox and name it 'PasswordTextBox' Create a Button named 'Cancel' and one more Button named 'OK' This code goes under the Form: Public Class LoginForm ' TODO: Insert code to perform custom authentication using the provided username and password ' (See http://go.microsoft.com/fwlink/?LinkId=35339). ' The custom principal can then be attached to the current thread's principal as follows: ' My.User.CurrentPrincipal = CustomPrincipal ' where CustomPrincipal is the IPrincipal implementation used to perform authentication. ' Subsequently, My.User will return identity information encapsulated in the CustomPrincipal object ' such as the username, display name, etc. Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click frmMain.UserName = Me.UsernameTextBox.Text frmMain.Password = Me.PasswordTextBox.Text frmMain.Show() Me.Visible = False End Sub Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click Me.Close() End Sub End Class HTH, Ryan--- -- Show quoteHide quoteRyan--- If this information was helpful, please indicate this by clicking ''Yes''. "Cor Ligthert[MVP]" wrote: > What OS are you using, on this page you see how to set the SMTP service for > XP prosional and things like that. > > http://www.emailarchitect.net/webapp/smtpcom/developers/smtpservice.asp > > Cor > > > > "ryguy7272" <ryguy7***@discussions.microsoft.com> wrote in message > news:20A3C817-BEB9-4E70-8670-AA98A87CDEB0@microsoft.com... > > Welcome to the party Cor. I think you’re right; I think it has something > > to > > do with the SMTP. I’m still missing something here but I can’t tell what > > it > > is. Can you please walk me through the process, step by step? You said > > that > > I need to, ‘activate SMTP in the program and feature setting’. What does > > this mean? I did some research on this for about an hour today and made > > almost no progress on this. I guess ‘web.mail version is deprecated’. > > What > > does that mean? How do I give my 192.xxx IP address in a dynamic way? > > What > > do I click on? What are the steps? I have 5 .NET books, and none of them > > discuss the topic of sending emails via SMTP. I am delighted to be > > learning > > this stuff, but I seem to have hit a wall, and I don’t know what to do > > next. > > > > Any and all help is greatly appreciated. > > Ryan--- > > > > > > -- > > Ryan--- > > If this information was helpful, please indicate this by clicking ''Yes''. > > > > > > "Cor Ligthert[MVP]" wrote: > > > >> Rguy, > >> > >> To use SMTP mail you have to activate that in the program and feature > >> setting (in fact the features) > >> > >> Be aware that the web.mail version is deprecated, use this one instead > >> > >> http://msdn.microsoft.com/en-us/library/system.net.mail.aspx > >> > >> Be aware that you can use your local host (IP address 127.0.0.1) as a > >> server > >> or the mail.server from your provider, mostly those don't like that. > >> > >> But don't use a leased IP address on your computer from by instance the > >> 192 > >> range, this can be given by any router in a dynamic way. > >> > >> Cor > >> > >> > > ryguy7272 wrote:
> ' SMTPServer.Credentials = New You'd better get him to change his gmail password right now. Always blank > System.Net.NetworkCredential("X," "X") out things like real usernames and passwords when posting. Andrew
Cannot update Access Database
why not inherit from type 'b(Of a)' Problem with turning off Appication Frameworks and with posting al Email Archive program Compilation error Structures inside structures Test - dont bother to read Drawing images in asp.net Vb.net[2008] Combo box population from text file (40,000 lines!) Running App in design environment is very slow |
|||||||||||||||||||||||