0
나는 프로그램을 전송하는 간단한 전자 메일을 만들려고 노력하고 있지만,이 두 smtpclients메일 링 시도 개체 참조?
Dim client As SmtpClient
Dim SmtpServer As New SmtpClient()
당신이 SmtpServer
을 인스턴스화 있지만 client
을 선언하고 object reference not set to an instance of an object
Try
Dim mail As MailMessage
Dim client As SmtpClient
Dim SmtpServer As New SmtpClient()
Dim fromAddress As String
Dim toAddress1 As String
Dim toAddress2 As String
Dim toAddress3 As String
Dim subject As String
Dim message As String
SmtpServer.Credentials = New Net.NetworkCredential("*********@gmail.com", "**********")
client.UseDefaultCredentials = False
fromAddress = FromEmail.Text
If ToEmail1.Visible = True Then
toAddress1 = ToEmail1.Text
ElseIf ToEmail1.Visible = True And ToEmail2.Visible = True Then
toAddress1 = ToEmail1.Text
toAddress2 = ToEmail2.Text
ElseIf ToEmail1.Visible = True And ToEmail2.Visible = True And ToEmail3.Visible = True Then
toAddress1 = ToEmail1.Text
toAddress2 = ToEmail2.Text
toAddress3 = ToEmail3.Text
End If
subject = "Subject"
Message = "Message"
mail = New MailMessage(fromAddress, toAddress1, subject, Message)
client = New SmtpClient("Smtp.live.com")
client.Port = 587
Dim SMTPUserInfo As New System.Net.NetworkCredential("[email protected]", "password")
client.Credentials = SMTPUserInfo
client.Send(mail)
MsgBox("sent")
Catch ex As Exception
MsgBox(ex.Message.ToString())
End Try
어디에서 오류가 발생 했습니까? 오류 메시지의 전체 텍스트는 무엇입니까? 이 WebForms 또는 MVC입니까? 어떤 버전의 .NET? –
스택 오버플로에 오신 것을 환영합니다! 'NullReferenceException'의 거의 모든 경우는 같습니다. 일부 힌트는 "[.NET의 NullReferenceException은 무엇입니까?] (http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)"를 참조하십시오. –