473,796 Members | 2,728 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
14 4658
Many thanks cj for wonderful examples. How do attachments work?

Many Thanks

Regards

"cj" <cj@nospam.nosp amwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
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.Net workCredential( "me@myco.co m", "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 #11

"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
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.

Antivirus, at least the McAfee on my server, will also block messages that
aren't in MAPI.

I just went through that yesterday. McAfee was set to permit sending by the
popular email programs, and I had to add two extra exceptions for the .net
application - one when running the app directly in the development
environment, and another when running over the web. After poking around in
McAfee, I found a log stating what it was blocking, and then I added it to
the list of exceptions under McAfee's setting dealing with the block of
"mass email worms on port 25"

Jeff
--
Posted via a free Usenet account from http://www.teranews.com

Apr 28 '07 #12
cj
I haven't done much with them. But, I know it can be done. If I was
you I'd cut and paste my examples into a test prg and when they work try
adding attachments in a similar manner to recipients or the subject and
body text. I have a program that I use for testing little bits of code
and ideas. It's a form with 36 buttons currently and a couple of
textboxes and labels. Each button was added to test a bit of code.
When I wrote the apps that send email I made a button in the test
program and played with the code there until I got the button to send a
message. That is where the code I sent you came from. It'll be Monday
before I can look into attachments--and that's if I'm not swamped with
problems when I get in the office. Good Luck.

John wrote:
Many thanks cj for wonderful examples. How do attachments work?

Many Thanks

Regards

"cj" <cj@nospam.nosp amwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>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.Ne tworkCredential ("me@myco.co m", "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 28 '07 #13
Many thanks cj for wonderful examples. How do attachments work?

For the System.Net.Mail class:

http://www.systemnetmail.com/faq/3.4.1.aspx

For the System.Web.Mail class:

http://www.systemwebmail.com/faq/2.3.aspx

Thanks,

Seth Rowe

Apr 28 '07 #14
"Jeff" <no**@nothingX. comwrote in
news:46******** **************@ free.teranews.c om:
Antivirus, at least the McAfee on my server, will also block messages
that aren't in MAPI.
Isn't it better to run the "mailto:xx*@xxx .com" command instead? That way
the OS will automatically launch the default mail program without the need
to worry about the AV?
Apr 28 '07 #15

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

Similar topics

5
2638
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
4175
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
4384
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
2754
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
1864
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
2292
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
9685
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
10244
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...
1
10201
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
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
9061
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
7558
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
5454
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2931
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.