Mail program help

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts Page 1 of 1
Contributors
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Mail program help
muttley1968
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

Image

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.
User avatar
pip
VIP - Donator
VIP - Donator
Posts: 156
Joined: Tue Jul 12, 2011 3:13 am

Re: Mail program help
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 :D
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Re: Mail program help
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
Code: Select all
    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
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: Mail program help
Scottie1972
try to add
Code: Select all

Mail.EnableSsl = True

to your code since you are using Gmail.com

example:
Code: Select all
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
Refference Link:
http://geekswithblogs.net/TakeNote/arch ... 13974.aspx
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: Mail program help
CodenStuff
You may be missing SSL because I remember gmail being a rite pain for sending mail. Try adding this within the code:
Code: Select all
SmtpServer.EnableSsl = true
I think thats what it was :?

P.S. Scottie beat me to it while I was typing out my reply :lol:
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Re: Mail program help
muttley1968
thanks everyone that seems to have done the trick its a tab bit slow but ill just add a progressbar so people know it hasnt frozen
6 posts Page 1 of 1
Return to “Coding Help & Support”