-6

I am creating a vb app for mailing system to send cv through mail quickly .when i create a check box to save my email and password but it give me an error username and password error in code say username is not a member of window Application

    If email.Checked = True Then
        My.Settings.username = usernamebox.Text
        My.Settings.Save()
        My.Settings.Reload()
    End If
    If pass.Checked = True Then
        My.Settings.password = passwordbox.Text
        My.Settings.Save()
        My.Settings.Reload()
    End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Handles MyBase.Load
    usernamebox.Text = My.Settings.username
    passwordbox.Text = My.Settings.password
End Sub
Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As  System.EventArgs)
    Handles Clear.Click
    My.Settings.password = passwordbox.Text
    My.Settings.Reset()
    My.Settings.Reload()
    My.Settings.username = usernamebox.Text
    My.Settings.Reset()
    My.Settings.Reload()
    usernamebox.Text = Nothing
    passwordbox.Text = Nothing
End Sub

in this code My.Settings.username is giving me an error and My.Settings.password and please also guide me how to add BCC(blind carbon copy ) function in vb app....

Deduplicator
  • 44,692
  • 7
  • 66
  • 118

1 Answers1

1

From your screenshot, it looks like you haven't set your application's Settings.

Project Settings can be set by navigating to Project Properties > Settings:

enter image description here

When this has been done, they can be referenced and modified by using My.Settings.[setting], and saving them with My.Settings.Save(), as per se:

My.Settings.Username = "Foo"
My.Settings.Password = "Bar"
My.Settings.Save()

You can add any My.Settings property you want, but however you must ensure you choose the correct Type for your data.


Another question I answered may aid you in this respect, to quote:

A User setting creates new settings for each user account the application is run under, the Application setting makes it so that the settings are global and affects everyone regardless of what privileges they hold in the system.

There are also differences to how the settings are saved:

Application: Saves in the [project name].config file

User: Saves in <c:\Documents>\<username>\[LocalSettings\]ApplicationData\<companyname>\<appdomainname>_<eid>_<hash>\<version>

You can see more here on where the settings are saved.

Community
  • 1
  • 1
AStopher
  • 4,207
  • 11
  • 50
  • 75
  • @PakDefndr No, that's not how this website works. Please give feedback on whether what I provided worked for you. – AStopher May 31 '15 at 16:50
  • Cyber monkey bro thanks this pic is a solution i did it one more thing i want to know how to add bcc mail in it – Pak Defndr May 31 '15 at 17:08
  • @PakDefndr Please click the green tick next to the voting buttons, to signify that this is the answer. – AStopher May 31 '15 at 17:43