Change to email functionality - reposted.

  • Thread starter Thread starter Edward
  • Start date Start date
E

Edward

This thread was previously interrupted with a spurious answer. Cor's
suggestion of http://www.systemwebmail.net/, while a useful resource,
does NOT contain the answer to my question.


I use the function below to send email from my ASP.NET application.
When I last visited it about three weeks ago, it would display the
mail message on screen and require me (the user) to send it manually.
The sent message would appear in my "Sent" messages folder.

Now, having made no changes, it sends the message silently, in the
background, and sent messages do *NOT* appear in the "Sent" messages
folder. I know the message has been sent because I tested it with one
of my other email addresses.

I prefer the former functionality. Any ideas, anyone?

TIA

Edward

Public Sub SendEmail(ByVal TSRs As StringBuilder, ByVal MailTo As
String)

Dim mailMsg As New MailMessage()
Dim sbMessage As New StringBuilder()

' Build the email message body.
sbMessage.Append(Me.EmailSalutation & " " & Name)
sbMessage.Append(vbCrLf)
sbMessage.Append(vbCrLf)
sbMessage.Append(Me.EmailHeader)
sbMessage.Append(vbCrLf)
sbMessage.Append(TSRs.ToString)
sbMessage.Append(vbCrLf)
sbMessage.Append(Me.EmailFooter)
sbMessage.Append(vbCrLf)
sbMessage.Append(vbCrLf)
sbMessage.Append(Me.EmailValediction)
sbMessage.Append(vbCrLf)
sbMessage.Append(vbCrLf)
sbMessage.Append(LogonUser.UserFullName)

With mailMsg
.From = LogonUser.Email
.To = MailTo
.Subject = Me.EmailSubjectLine
.Body = sbMessage.ToString

End With

' Set the SmtpServer name. This can be any of the following
depending on
' your local security settings:

' a) Local IP Address (assuming your local machine's SMTP server has
the
' right to send messages through a local firewall (if present).

' b) 127.0.0.1 the loopback of the local machine.

' c) "smarthost" or the name or the IP address of the exchange
server you
' utilize for messaging. This is usually what is needed if you are
behind
' a corporate firewall.

SmtpMail.SmtpServer = "127.0.0.1"

Try
SmtpMail.Send(mailMsg)
Catch exp As Exception
End Try

End Sub
 
Hi Edward,

The code you are using is the SMTP server mail.
It sends messages from your IIS mail server part of your server.
(Probably your local host because you use that 127.0.0.1)
It goes silently, however the user sends no messages, it is your server,
which is sending the messages.

From your text I understand that you want to use that the user sends no
silent message, for that you can use this code.

Herfried is busy with this code and has improved it.
This is just to start with, I am sure that when Herfried sees the message he
sends his improved version.

However do you want that SMTP mail (what was more in the link I have
supported for you and what your code is, message that back)

Cor

\\\by Fergus Cooney & small correction Cor
'A reference to System.Web may be necessary
'in the Project for this Import to work.
Imports System.Web.HttpUtility

Public Sub StartDefaultMail (sTo As String, _
Optional sSubject As String = "", _
Optional sMessage As String = "")
Try
sTo = UrlEncode (sTo)
sSubject = sSubject
sMessage = sMessage
Process.Start ("mailto:" & sTo & "?subject=" _
& sSubject & "&body=" & sMessage)

Catch e As Exception
MsgBox ("Couldn't start default email application" _
& vbCrLf & e.Message)
'or
Throw New Exception ("Couldn't start default email app", e)
End Try
End Sub
///

I hope this helps,

Cor
 
* (e-mail address removed) (Edward) scripsit:
I use the function below to send email from my ASP.NET application.
When I last visited it about three weeks ago, it would display the
mail message on screen and require me (the user) to send it manually.
The sent message would appear in my "Sent" messages folder.

Now, having made no changes, it sends the message silently, in the
background, and sent messages do *NOT* appear in the "Sent" messages
folder. I know the message has been sent because I tested it with one
of my other email addresses.

I prefer the former functionality. Any ideas, anyone?

Opening the default mail client with a mail template:

Sample based on work by Fergus Cooney and Cor (mpdl.vb), optimized and
extended by Herfried K. Wagner [MVP]:

Add a reference to "System.Web.dll". Then you can use this code:

\\\
Imports System.Diagnostics
Imports System.Web

Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)
Process.Start(psi)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub
///

Usage:

\\\
StartDefaultMail( _
"(e-mail address removed)", _
"Invitation", _
"Do you want to come to my party?" _
)
///
 
This thread was previously interrupted with a spurious answer. Cor's
suggestion of http://www.systemwebmail.net/, while a useful resource,
does NOT contain the answer to my question.


I use the function below to send email from my ASP.NET application.
When I last visited it about three weeks ago, it would display the
mail message on screen and require me (the user) to send it manually.
The sent message would appear in my "Sent" messages folder.

Now, having made no changes, it sends the message silently, in the
background, and sent messages do *NOT* appear in the "Sent" messages
folder. I know the message has been sent because I tested it with one
of my other email addresses.

I prefer the former functionality. Any ideas, anyone?

[...]

First of all, thanks for the help which I will test later today.

What interests me most, however, is WHY did my code USED to display
the mail message for me to edit and send manually, and then a few
weeks later (with no changes, or upgrades of which I am aware) it does
the whole thing silently, in the background.

Edward
 
Back
Top