Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

I am having problems with this program i have written

$
0
0
[Private Sub sendmail_Click(ByVal sender As Object, ByVal e As System.EventArgs)]
[Dim from As String]
[Dim recipient As String]
[Dim bcc As String]
[bcc = bcc.ToString]
[Dim cc As String]
[cc = cc.ToString]
[Dim subject As String]
[Dim body As String]

[SendMailMessage(from, recipient, bcc, cc, subject, body)]
[End Sub]

[Public Shared Sub SendMailMessage(ByVal from As String, ByVal Recipient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)]
[Dim mMailMessage As New MailMessage()]
[mMailMessage.From = New MailAddress(from)]

[mMailMessage.To.Add(New MailAddress(Recipient))]

[If Not bcc Is Nothing And bcc <> String.Empty Then]
[mMailMessage.Bcc.Add(New MailAddress(bcc))]
[End If]
[If Not cc Is Nothing And bcc <> String.Empty Then]
[mMailMessage.CC.Add(New MailAddress(cc))]
[End If]

[mMailMessage.Subject = subject]]
[mMailMessage.Body = body]


[mMailMessage.Priority = MailPriority.High]


[Dim mSmtpClient As New SmtpClient()]
[mSmtpClient.EnableSsl = True]
[mSmtpClient.Port = 587]]




[Try]
[mSmtpClient.Send(mMailMessage)]
[Catch ex As Exception]
[ MsgBox("Failed to send emai]l!")]

[End Try]
[End Sub]

The user inputs email details to the parameters enclosed within send mailmessage. These parameters are then passed to function public shared sub send mailmessage to be processed so they can send email. But I get no email I also get no errors just a couple of warnings. I am trying to send via gmail servers but i get no email .Please see this web config file:

[</system.web>]
[<system.net>]
[<mailSettings>]
[<smtp from="user@gmail.com">]
[<network host="smtp.googlemail.com" password="password" userName="username@gmail.com" />]
[</smtp>]
[</mailSettings>]
[</system.net>]
[</configuration>]

I am not sure this is written correctly?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>