Hello i am currently buildling an application that uses gmail and on the computer it is built on no problems at all work fine not a single error but the second i run it on ANY other computer weather i am loged into that gmail account or not i get this error
I really need to get this fixed as it is the last known issue in my program and then its just working on graphics and it will be finished.
Re: Mail program help
Posted: Sat Nov 24, 2012 8:12 pm
by pip
What is code for line 25 of form1 and is it a button click? the problem is with that line it looks like from error. @ #muttley1968
I don't know if i can help but i am willing to try
Re: Mail program help
Posted: Sat Nov 24, 2012 10:29 pm
by muttley1968
This is the code for the hole button of which the
mail.send section is line 25 of my code
only diffrence between this code and my program is that i have removed my pass and put it to 12345 so you dont know my actaull password
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential("xprograming.manning516@gmail.com", "12345")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress(TextBox2.Text)
mail.To.Add("xprograming@gmx.co.uk")
mail.Subject = "Test Mail"
mail.Body = ((Label1.Text + TextBox1.Text) & vbCrLf & (Label2.Text + TextBox2.Text) & vbCrLf & (Label3.Text + TextBox3.Text) & vbCrLf & (Label4.Text + TextBox4.Text))
PictureBox3.Image.Save(ms, ImageFormat.Png)
ms.Position = 0
mail.Attachments.Add(a)
SmtpServer.Send(mail)
MsgBox("mail sent")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Imports System.Net.Mail
'Start by creating a mail message object
Dim MyMailMessage As New MailMessage()
'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress("from_address_here@gmail.com")
'To is a collection of MailAddress types
MyMailMessage.To.Add("to_address_here@domain_name_here")
MyMailMessage.Subject = "GMail Test"
MyMailMessage.Body = "This is the test text for Gmail email"
'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("account uid", " account pwd")
SMTPServer.EnableSsl = True
Try
SMTPServer.Send(MyMailMessage)
MessageBox.Show("Email Sent")
Catch ex As SmtpException
MessageBox.Show(ex.Message)
End Try