[RESOLVED] Showing another forms using showdialog
Hello everyone I make a program upon sending emails to my friends using smtp. The problem is that I have confusions why my another form will not show until it is not finished sending all of the messages. I want my next form to show how many percent were finished but the problem is that my form will show only until all the emails are sent on my listbox. I put my code on the load event of the form. Am I incorrect upon viewing my form? Thanks everyone.
Re: Showing another forms using showdialog
Would you like to share your code with us? Otherwise its all just guesswork in the dark.
Re: Showing another forms using showdialog
i think u have a function in load form which sends emails (Syn) or whatever, then u have a function or code that shows ur next form..
Its just a Guess in the DARK..
Re: Showing another forms using showdialog
This is what in my form2 load event:
Code:
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim i As Integer
Dim j As Integer
With ListView1
For i = 0 To frmMain.ListView1.Items.Count - 1
Dim LVITem As New ListViewItem
' Create some text (= read in from data source)
LVITem.Text = frmMain.ListView1.Items(i).SubItems(0).Text '& i.ToString
' Add it to the ListView
.Items.Insert(0, LVITem)
' Add the sub items (= read in from data source)
LVITem.SubItems.Add(frmMain.ListView1.Items(i).SubItems(1).Text)
LVITem.SubItems.Add("")
Next
For j = 0 To ListView1.Items.Count - 1
holder = ListView1.Items(j).SubItems(1).Text
sendHTMLmail()
Next
End With
End Sub
And this is my sub sendHTML
Code:
Sub sendHTMLmail()
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Object
Dim schema As String
Dim i As Integer
nfi.NumberDecimalDigits = 0
nfi.NumberGroupSeparator = ","
iMsg = CreateObject("CDO.Message")
iConf = CreateObject("CDO.Configuration")
Flds = iConf.Fields
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpserver") = frmMain.txtSMTPServer.Text
Flds.Item(schema & "smtpserverport") = CInt(frmMain.txtSMTPPort.Text)
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = frmMain.txtUsername.Text
Flds.Item(schema & "sendpassword") = frmMain.txtPassword.Text
Flds.Item(schema & "smtpusessl") = 1
Flds.Update()
Try
With iMsg
.To = holder
.From = frmMain.txtFrom.Text
.Sender = frmMain.txtFromDisplayName.Text
.ReplyTo = frmMain.txtReplyTo.Text
If frmMain.txtAttachment.Text.Length = 0 Then
.Subject = frmMain.txtSubject.Text
.HTMLBody = frmMain.RichTextBox2.Text
.Organization = "Arabian Publications Inc."
.Configuration = iConf
.Send()
Else
.AddAttachment(frmMain.txtAttachment.Text)
.Subject = frmMain.txtSubject.Text
.HTMLBody = frmMain.RichTextBox2.Text
.Organization = "Arabian Publications Inc."
.Configuration = iConf
.Send()
End If
End With
iMsg = Nothing
iConf = Nothing
Flds = Nothing
For i = 0 To ListView1.Items.Count - 1
ListView1.Items(i).SubItems(2).Text = "Sent Successfully"
Next
Catch ex As Net.Mail.SmtpException
MsgBox(iMsg.GetLastErrDescription, vbOKOnly, "ANSMTP COM Object")
End Try
End Sub
the second column of my listview contains the email ids and i want to fill the next row to it if it will be successfully sent or not. Thanks everyone for the reply.
Re: Showing another forms using showdialog
Not sure if this applies, but if you put Form1.ShowDialog in Form1's Load Event, then it will not finish loading until you do something on Form2.
Re: [RESOLVED] Showing another forms using showdialog
thanks for the information everyone.. have a nice day.. :)