473,950 Members | 60,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending an email (an easy way)

hello, In my application I want to send an email when a certain event
ocuurs. It should pop-up the user's email client and fill in the send to
address and subject and body. Kind of like I can do with
mailto:us**@dom ain.com in HTML. Since it will be installed on the server
and run over the network I won't be able to install the office PIA on every
users machines. Is there a really simple way to do this?
Nov 20 '05 #1
2 1143
* "Josh Golden" <jo***@wachovia .com> scripsit:
hello, In my application I want to send an email when a certain event
ocuurs. It should pop-up the user's email client and fill in the send to
address and subject and body.


My FAQ:

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.Diagnost ics
Imports System.Web

Public Sub StartDefaultMai l( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
Try
Dim psi As New ProcessStartInf o
psi.UseShellExe cute = True
psi.FileName = _
"mailto:" & HttpUtility.Url Encode([To]) & _
"?subject=" & HttpUtility.Url Encode(Subject) & _
"&body=" & HttpUtility.Url Encode(Message)
Process.Start(p si)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub
///

Usage:

\\\
StartDefaultMai l( _
"fo*@goo.ba z", _
"Invitation ", _
"Do you want to come to my party?" _
)
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
I've tried to use the code listed below, but have run into a problem.

It replaces all spaces in Message and Subject with + signs.

So that something like

Message = "This is the information you requested."

Comes out as

This+is+the+inf ormation+you+re quested.

In Outlook's message window. This is launching Outlook 2000 SP3 on Windows
XP.

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:2j******** *****@uni-berlin.de...
* "Josh Golden" <jo***@wachovia .com> scripsit:
hello, In my application I want to send an email when a certain event
ocuurs. It should pop-up the user's email client and fill in the send to address and subject and body.


My FAQ:

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.Diagnost ics
Imports System.Web

Public Sub StartDefaultMai l( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
Try
Dim psi As New ProcessStartInf o
psi.UseShellExe cute = True
psi.FileName = _
"mailto:" & HttpUtility.Url Encode([To]) & _
"?subject=" & HttpUtility.Url Encode(Subject) & _
"&body=" & HttpUtility.Url Encode(Message)
Process.Start(p si)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub
///

Usage:

\\\
StartDefaultMai l( _
"fo*@goo.ba z", _
"Invitation ", _
"Do you want to come to my party?" _
)
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7069
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt. Obviuosly, the file is fine on the server, so the attachment code I am using must be corrupting it, but I dont know what it is: // send email with attachment function emailAttachment($to, $subject, $message, $name, $email,
13
3246
by: joe215 | last post by:
I want my users to send emails from a Windows app that I am developing in Visual Basic.NET 2003. I found a good example of sending email to a SMTP server using the SmtpMail class. However, using this, it seems, that the user must install IIS on their computer. Isn't there a class that will detect whatever mail server is available on a computer and use that? How do I create this functionality without having the user add any other...
2
2101
by: Del | last post by:
I have two question on sending email messages from MS Access (Versio 2000, 2002, and 2003). I have a form with a command button to send an email message, the code behide the button is as follows; ============================================================================= Dim strRecipient As String Dim strSubject As String Dim strMessageBody As String
8
1948
by: Adam Clauss | last post by:
I have a folder containing many subfolders (and subfolders and....) all containing various .cs files. Is there any "easy" way to get them all added to the solution. Preferable would be that the folders are actually created in the Solution Explorer so that I can find things easily. Its easy to select multiple files out of a single folder, but not recursively into subfolders. Any ideas? -- Adam Clauss
17
2920
by: Bonj | last post by:
Right guys. (I would like a solution to this in VB6 as this is what our needy app is written in, but any solutions that involve .NET would be much appreciated likewise as I could instantiate them, otherwise please forgive the crossposting.) I'm sure I've seen posts here before criticising the practice of automating outlook for the purpose of programatically sending email, on the grounds that it's naff. Well now we're really landed in...
2
1183
by: SenthilVel | last post by:
Hi I do need to send Emails from my c# dotnet application. I know that the easy way is to use System.web.mail components .. The problem is that the Mail components in DOtnet use the CDO inbuilt within them... but i dont want to use these CDO components to send mails....
1
2305
by: stax | last post by:
Hello, I would like to add a Send Feedback feature to my application. Does anybody know or easy way to do this, any applications that do this, articles, samples or anything else that could give me some hints. I tried to look how Reflector implements this but couldn't find anything. I'm using .NET 2.0, there is a class called SmtpClient, can I use this class with my personal yahoo mail account? thx
6
1863
by: Jack | last post by:
Hi, I am still new to .NET so, i'm sorry if my question is a bit too simple :-) I would like to know what is the "best-practice-way" of sending email from asp.net (VbScript). I want to make a "contact us" page for my website. Tnx.
31
12772
by: happyse27 | last post by:
Hi All, I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it is working for normal email servers, but NOT with gmail server, I am very puzzled still!!) Codes(item c below) It keeps complaining and logs and codes are below. a) apache access logs --------------------------------- 127.0.0.1 - - "GET...
6
9217
by: Chocolade | last post by:
Hi, Im using System.Net.Mail to send email in my application it was working great without any problems untill this morning after like 20-30 tries it was sending the email ok then suddenly this morning i got an exception and i cant figure out what/where the problem is and how to fix it. The problem say i have some invalid char: invalid character was found in the mail header: 'י'. Now this char 'י' is an hebrew letter. But i searched...
0
10172
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9904
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8269
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7444
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6353
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4554
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3559
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.