我需要公共职能帮助 [英] I need Public Function Help

查看:90
本文介绍了我需要公共职能帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我了解此公共功能有什么问题吗?

Can someone help me understand what's wrong with this Public Function?

    Public Function EmailSender()
        Try
            Dim smtpserver As New SmtpClient()
            Dim mail As New MailMessage()
            smtpserver.Credentials = New Net.NetworkCredential("myname@gmail.com", "password")
            smtpserver.Port = 465
            smtpserver.Host = "smtp.gmail.com"
            mail = New MailMessage()
            mail.From = New MailAddress("myname@gmail.com")
            mail.To.Add("to mail id")
            mail.Subject = ("Subject Name")
            mail.Body = ("Body text")
            smtpserver.Send(mail)
            MsgBox("Mail Sent")
        Catch ex As Exception
            Close()
        End Try
    End Function

推荐答案

有人可以帮助我了解此公共功能有什么问题吗?

Can someone help me understand what's wrong with this Public Function?

您需要描述问题所在.是否有错误,或者代码没有按照您的期望去做?如果有错误,则需要显示确切的错误消息及其出现的行.如果代码没有做什么 然后,您需要描述期望发生的事情和实际发生的事情.

You need to describe what the problem is.  Is there an error, or does the code not do what you expect it to do?  If there is an error then you need to show the exact error message and the line where it occurs.  If the code is not doing what you want then you need to describe what you expected to happen and what actually happened.

您的尝试/捕获"处理实际上对错误没有任何作用,因此应将其删除.然后,如果有错误,您将能够看到详细信息.

Your Try/Catch handling doesn't actually do anything with the error, so it should be removed.  Then, if there is an error, you will be able to see the details.


这篇关于我需要公共职能帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆