I created an even on a form called Sub New so I can handle some events and close the window down if there is an error.
Upon doing that, I came across 3 errors that I don't know how to fix.
vb.net Code:
Me.Hide()
frmEmail.SetReportDate = #1/23/2012#
frmEmail.Show()
frmEmail.Dispose()
Me.Show()
I get 3 errors, on lines 3, 4 and 5
Reference to a non-shared member requires an object reference
How can I fix this? Note: ShowDialog really isn't necessary I could just use .Show. I want to use ShowDialog because the line under those 3 shows the current form.
Found the problem (I had private sub new) but now a new problem...
How do I pass the date to the form?
In case it's relavent, my code for sub new on frmEmail.
vb.net Code:
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Dim strHTML As String = String.Empty
Dim Subject As String = "Service Assignments for " & ReportDate.ToString(myDateFormat)
Dim oApp As Outlook._Application
Dim oMsg As Outlook._MailItem
Dim YesNo As DialogResult = Windows.Forms.DialogResult.Yes
Dim NoErrors As Boolean
Me.Text = "Service Assignments for " & ReportDate.ToLongDateString
setHeader()
NoErrors = setData()
setFooter()
strHTML = reportHeader & reportData.ToString & reportFooter
oApp = New Outlook.Application()
oMsg = CType(oApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook._MailItem)
oMsg.Subject = Subject
oMsg.HTMLBody = strHTML
oMsg.To = "DTGOn-RentHelpDesk"
oMsg.Importance = Outlook.OlImportance.olImportanceHigh
oMsg.Display()
YesNo = MessageBox.Show("Did the email show up?", Application.ProductName, _
MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button1)
If Not NoErrors Then
Me.Close()
Else
If YesNo = Windows.Forms.DialogResult.No Then
ieWeb.Document.Write(strHTML)
Me.Show()
Else
MessageBox.Show("Push Send in the email window to send!", "Send Email Alert", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
NoErrors = False
oMsg2 = oMsg
End If
End If
End Sub