电子邮件。从数据库中解决

编程入门 行业动态 更新时间:2024-10-20 07:48:07
本文介绍了电子邮件。从数据库中解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下方法

I have below method

Private Sub SendHtmlFormattedEmail(ByVal recepientEmail As String, ByVal subject As String, ByVal body As String) Dim mailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage Try mailMessage.From = New MailAddress(ConfigurationManager.AppSettings("UserName")) ' mailMessage.CC.Add("danish.habib@plan-international") mailMessage.Bcc.Add("spober_woh@yahoo") mailMessage.Subject = subject mailMessage.Body = body mailMessage.IsBodyHtml = True mailMessage.To.Add(New MailAddress(recepientEmail)) Dim files As List(Of HttpPostedFile) = DirectCast(Cache(Me.Key), List(Of HttpPostedFile)) For Each file As HttpPostedFile In files mailMessage.Attachments.Add(New Attachment(file.InputStream, Path.GetFileName(file.FileName), file.ContentType)) Next mailMessage.From = New MailAddress("omer@planrbme.pk") Dim smtp As New SmtpClient() smtp.Host = "202.165.228.15" smtp.EnableSsl = False smtp.Credentials = New System.Net.NetworkCredential("omer@planrbme.pk", "Pakistan_123") smtp.Port = 25 smtp.Send(mailMessage) Catch ex As Exception ex.Message.ToString() End Try End Sub

当我从下面的数据库中获取mail.To地址 mailMessage.To.Add(新邮件地址(recepientEmail))然后它没有向我的电子邮件地址发送任何电子邮件,它也没有给出任何例外,但当我硬编码时它就像 mailMessage。 To.Add(d.habib@plan-international)它发送电子邮件到那个地址为什么会这样? 我试过的: 我试图发送电子邮件到谷歌帐户,如marktabor@gmail它发送正确它没有发送只是与这个域和当我我正在使用该方法获得电子邮件地址,然后它正确地收到电子邮件,如d.habib@plan-international但它没有发送到该电子邮件,当我硬编码然后它发送电子邮件到该地址

When i am getting the mail.To address from the database like below mailMessage.To.Add(New MailAddress(recepientEmail)) then it did not send any email to my email address it did not give any exception as well , but when i hard code it like mailMessage.To.Add("d.habib@plan-international") it send email to that address why it is so? What I have tried: I have tried to send email to google account like marktabor@gmail it send correctly it did not send just with this domain and when i am using the method to get the email address then it gets the email correctly like d.habib@plan-international but it did not send to that email when i hard code it then it send email to that address

推荐答案

我们无法分辨 - 问题可能不在代码中,而是在调用它的代码中。 所以使用调试器:在第一行放置一个断点Sub和调试器点击时它会查看你作为 recepientEmail 字符串传递的确切内容。 如果它不是你所期望的 - 我怀疑它不会 - 使用调用堆栈回顾你的代码,找出原因是什么。 但我们不能为你做任何事情 - 我们不这样做拥有其余的代码,因此我们无法运行它,因为我们没有您的数据为我们提供相同的值,所以它无济于事! We can't tell - the problem probably isn't in that code but in the code that calls it. So use the debugger: put a breakpoint on the first line of that Sub and when the debugger hits it look at exactly what you got passed as a recepientEmail string. If it's not what you expected - and I suspect it won't be - use the Call Stack to look back in your code to find out why it is what it is. But we can't do any of that for you - we don't have the rest of your code, so we can't run it, and it wouldn't help anyway as we don't have your data to provide us with the same values!

更多推荐

电子邮件。从数据库中解决

本文发布于:2023-10-30 04:22:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541752.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   电子邮件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!