Hi All,
Im trying to configure a email within .net i have 5 varibles which im putting in to the email which are (EmailFrom, NewUserEmail, EmailSubject, EmailBody, EmailFromName) my ObjMailMessage accepts the first 4 but when i add the last one EmailFromName it throws an error which is "Overload resolution failed because no accessible 'New' accepts this number of arguments"
So im kinda puzzled on how i can get this to work because i need to send a email with the 5 varibles passed in, later on down the line this may increase to at least 7-10 heres my code
First part is the Email
heres the Send Method where the error is shownCode:Try FromUserEmail = FromEmail ToUserEmail = ToEmail QuestionMessage = Message EmailFromName = FromName Dim ReturnText As String = String.Empty EmailSubject = "Email Regarding Item: " & ItemTitle EmailBody = "<html><head><title>ChaucerAuction - Auction Email</title>" EmailBody &= "<link href='#' type='text/css'rel='stylesheet' />" EmailBody &= " </head><body><div align='right'><img src='#'/>" EmailBody &= "</div><div align='left' style='margin-left:40px; margin-top:10px' class='emailtext'>" EmailBody &= "Hi " & OwnerName & _ "<br/><br/>Just a quick email to find out: <br/><br/><b> " & _ Message & ".</b><br/><br/>" & _ "Kind Regards<a class='menuItem' " & _ FromName & _ "<br/><br/>" & _ "<br/><br/>" EmailBody &= "</div></body></html>" Send() Catch ex As Exception ErrorText &= "An error has occurred in Email.Send : " & ex.Message & vbCrLf End Try
And there declared like thisCode:Public Sub Send() Try Dim objMailMessage As New MailMessage(EmailFrom, NewUserEmail, EmailSubject, EmailBody, EmailFromName) objMailMessage.IsBodyHtml = True 'Send message Dim SmtpClient As New Net.Mail.SmtpClient("SMTPServer") SmtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis SmtpClient.UseDefaultCredentials = True SmtpClient.Send(objMailMessage) Catch ex As Exception ErrorText &= "An error has occurred in Email.Send : " & ex.Message & vbCrLf End Try End Sub
Im stumpedCode:Private FromUserEmail As String = String.Empty Private ToUserEmail As String = String.Empty Private Private EmailSubject As String = String.Empty Private EmailBody As String = String.Empty Private EmailFromName As String = String.Empty![]()




Reply With Quote