473,785 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending email from within app

Hi

How does one send email from within a vb.net app?

Thanks

Regards
Apr 27 '07 #1
14 4657
"John" <Jo**@nospam.in fovis.co.ukwrot e in news:OnwQ$ZNiHH A.4228
@TK2MSFTNGP03.p hx.gbl:
Hi

How does one send email from within a vb.net app?

..NET 1.1 System.Web.Mail

..NET 2.0 System.Net.Mail
Apr 27 '07 #2
cj
There are several ways. Also depends on if your using 2003 or 2005.
I'll pull some of my code and get back to you.
John wrote:
Hi

How does one send email from within a vb.net app?

Thanks

Regards

Apr 27 '07 #3
cj
Here's a simple way

Public Sub StartMail(ByVal [To] As String, Optional ByVal subj As String
= "", Optional ByVal Body As String = "")
Try
Dim mailProcess As New ProcessStartInf o
mailProcess.Use ShellExecute = True
mailProcess.Fil eName = "mailto:" & [To] & "?subject=" &
subj & "&body=" & Body
Process.Start(m ailProcess)
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

Here's my favorite way but it's 2005 only

Dim msg As New System.Net.Mail .MailMessage
Dim smtp As New System.Net.Mail .SmtpClient
msg.From = New System.Net.Mail .MailAddress("m e@myco.com")
msg.To.Add("bo* @ACME.com")
msg.Subject = "Test Msg"
msg.Body = "Can you hear me now?"
smtp.Host = "smtp.myco. com"
smtp.Port = 25
smtp.DeliveryMe thod = Net.Mail.SmtpDe liveryMethod.Ne twork
smtp.Credential s = New
System.Net.Netw orkCredential(" me@myco.com", "mypass")
smtp.Send(msg)
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try

Got one more I'll find later.
John wrote:
Hi

How does one send email from within a vb.net app?

Thanks

Regards

Apr 27 '07 #4
On Apr 27, 10:15 am, "John" <J...@nospam.in fovis.co.ukwrot e:
Hi

How does one send email from within a vb.net app?

Thanks

Regards
You should find your answers here:

www.systemnetmail.com
www.systemwebmail.com

Thanks,

Seth Rowe

Apr 27 '07 #5
cj
Here's the other. I haven't used it in 2005 yet but in 2003 I did. I
used it to give a user of an app the option to send the contents of say
a text box to someone. It brings up their default mail and puts the
contents and subject in but leaves who they're sending it to blank and
allows them to edit the message etc and send it themselves.

My 2005 example in the previous email is used by some of my programs to
wake us up in the middle of the night with an email to our cell phones
because something happened it didn't like. :( In other words it is a
totally automatic generate and send of a message.

I don't quite remember how the sendto: works any more--it didn't do what
I wanted.

There are other ways to do this but these are all the examples I have.
Private Sub SndMAPIMail(ByV al subj As String, ByVal msg As String)
Try
Dim myMAPISession As New MSMAPI.MAPISess ion
Dim myMAPIMessage As New MSMAPI.MAPIMess ages

myMAPISession.D ownLoadMail = False
myMAPISession.S ignOn()
myMAPISession.N ewSession = True

myMAPIMessage.S essionID = myMAPISession.S essionID

myMAPIMessage.C ompose()

myMAPIMessage.M sgSubject = subj
myMAPIMessage.M sgNoteText = msg

Try
myMAPIMessage.S end(True)
Catch ex As Exception
If Not ex.Message = "User cancelled process" Then
MessageBox.Show (ex.Message)
End If
End Try

myMAPISession.S ignOff()
myMAPISession.N ewSession = False
Catch
End Try
End Sub
cj wrote:
Here's a simple way

Public Sub StartMail(ByVal [To] As String, Optional ByVal subj As String
= "", Optional ByVal Body As String = "")
Try
Dim mailProcess As New ProcessStartInf o
mailProcess.Use ShellExecute = True
mailProcess.Fil eName = "mailto:" & [To] & "?subject=" & subj
& "&body=" & Body
Process.Start(m ailProcess)
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

Here's my favorite way but it's 2005 only

Dim msg As New System.Net.Mail .MailMessage
Dim smtp As New System.Net.Mail .SmtpClient
msg.From = New System.Net.Mail .MailAddress("m e@myco.com")
msg.To.Add("bo* @ACME.com")
msg.Subject = "Test Msg"
msg.Body = "Can you hear me now?"
smtp.Host = "smtp.myco. com"
smtp.Port = 25
smtp.DeliveryMe thod = Net.Mail.SmtpDe liveryMethod.Ne twork
smtp.Credential s = New
System.Net.Netw orkCredential(" me@myco.com", "mypass")
smtp.Send(msg)
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try

Got one more I'll find later.
John wrote:
>Hi

How does one send email from within a vb.net app?

Thanks

Regards
Apr 27 '07 #6
cj <cj@nospam.nosp amwrote in news:#N******** ******@TK2MSFTN GP06.phx.gbl:
Dim myMAPISession As New MSMAPI.MAPISess ion
Dim myMAPIMessage As New MSMAPI.MAPIMess ages
I would avoid using MAPI unless the user has MS Outlook.

Apr 27 '07 #7
cj
????

I use Thunderbird and most folks use Outlook here and it works fine for
us as I have it in the example. Fine being the way I want it too that
is. Seems I do recall something that was different in the way Outlook
and Thunderbird responded to it but can't remember what.
Spam Catcher wrote:
cj <cj@nospam.nosp amwrote in news:#N******** ******@TK2MSFTN GP06.phx.gbl:
> Dim myMAPISession As New MSMAPI.MAPISess ion
Dim myMAPIMessage As New MSMAPI.MAPIMess ages

I would avoid using MAPI unless the user has MS Outlook.
Apr 27 '07 #8
cj <cj@nospam.nosp amwrote in news:OH******** ******@TK2MSFTN GP05.phx.gbl:
I use Thunderbird and most folks use Outlook here and it works fine for
us as I have it in the example. Fine being the way I want it too that
is. Seems I do recall something that was different in the way Outlook
and Thunderbird responded to it but can't remember what.
MAPI is Messaging API... if you have an antivirus it often blocks MAPI
commands. MAPI can only relied on in an enterprise environment in which you
have complete control of the computers.
Apr 27 '07 #9

See (and download code)
/8/2006
Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)
http://sholliday.spaces.live.com/blog/

The code is in C#, but you can learn the principals.

"John" <Jo**@nospam.in fovis.co.ukwrot e in message
news:On******** ******@TK2MSFTN GP03.phx.gbl...
Hi

How does one send email from within a vb.net app?

Thanks

Regards


Apr 27 '07 #10

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

Similar topics

5
2636
by: BaWork | last post by:
I have a web form where a client can select which site members to send an email to. This form is populated from the contents of the member table, so the form can have 0-x names listed on it depending on member expiration dates. When the form is submitted, the code loops through the form contents and sends an email to those members that meet the selected criteria. All this worked perfectly when I was sending text emails, but since I
1
4172
by: Devonish | last post by:
I am composing an email with Access VB and then sending it from within Access. Everything works correctly (the email actually goes!) but Outlook ask some irritating questions that the user is required to answer. A summary of the relevant code is: Dim mailObj as Outlook.MailItem
8
4383
by: Frank | last post by:
I think I've confused myself completely here :-) I have used System.Web.Mail, but am not sure if this works with Exchange Server 5.5. I asked the client if they're email server supported SMTP, and got the following reply (exact quote): Exchange 5.5 uses IMS connector for communication between the internal and the external world. IMS is based on SMTP Protocol. For mail flow within the organization Exchange 5.5 uses Message Transfer...
6
2751
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
0
1213
by: Jim Devenish | last post by:
I wish to send a copy of an email to a selected number of recipients. I can do this when the email contains only text but have a problem when the email contains a picture. I create a new email with a picture inserted into its body and save it in the Drafts folder. I then, from within Access, send a copy of this to a number of people. Everything works well except that the picture is not copied, only its surrounding text.
3
332
by: JaffaCakes | last post by:
I want to send an email confirmation after a user completes a form on our Internet page. I am testing this with the System.Web.Mail.SmtpMail class. If I do a SmtpMail.Send then the message takes days to reach the recipient. It is possible to set the SmtpServer but what will it be as the webserver is sitting on the otherside of our firewall so our Exchange Server address will be of no use. Can someone help? I am probably barking up the...
1
2156
by: gemma.gill | last post by:
Hi There, I have a button on a form within access that sends a verification e- mail. My problem is that these e-mails are sending from individual user accounts rather than a genieric mailbox. Is there a way to do this? We are using MS Outlook each user has an account set up that gives them a personal mailbox and access to another mailbox "helpdesk". I
2
1863
by: Smithers | last post by:
I have a service that will periodically send email messages to system adminstrators. I would like for this service to send a email notification whenever the service is started and when it is stopped. I placed attempted to do that from the OnStart event procedure... but any messages sent during the OnStart procedure are not sent. But when the service is stopped, the email messages from both the OnStart and OnStop event procedure are sent. ...
1
2290
by: Mel via AccessMonster.com | last post by:
I have four people on my email list. I want to send one email each of the four people with a list of accounts over due, embodied within the email. So, for instance, jeff will be sent an email that shows in the body of the email all of his accounts that are over due: account #1 ABC Inc past due on 3/12/2008 Account #2 DEF inc past due on 4/1/2008
0
9647
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
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
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
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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
7509
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
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.