You are here:   Home
Register   |  Login
ThinkStock

Captured Technology - Blog

Minimize

Sending eMails within a .Net Application

Dec 29

Written by:
12/29/2008 3:26 PM  RssIcon

Sending eMails within a .Net application is fairly simple with the use of the System.Net.Mail namespace.

First, import the class:

Imports System.Net.Mail

Then create a function to provide for sending the emails within a public class:

Public Shared Function SendEmail(ByVal strFrom As String, _
                       ByVal strTo As String, _ 
                       ByVal strSubject As String, _
                       ByVal strBody As String) As MailMessage 
        Dim objReturn As New MailMessage 

        Try 
            Dim objMail As New MailMessage(strFrom, strTo) 
            objMail.Subject = strSubject 
            objMail.Body = strBody 
            Dim SmtpMail As SmtpClient = New SmtpClient("smtp.mail.com") 
            SmtpMail.Send(objMail) 
            objReturn = objMail 
        Catch ex As Exception 
            objReturn = Nothing 
        End Try 

        Return objReturn 
    End Function

The Smtp client will be your local client.

Call this function from anywhere within your application or webpage.

Tags:
Categories:

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 

FaceBook

Minimize

Mobile Version

Minimize
Add CapturedTech - Technology Mippin widget

Translate

Minimize

Sponsors

Minimize
Design your own Fandango Bucks gift card!

Recent Comments

Minimize
Re: Three Benefits to Using a Royalty-Free Image on Your Website or Blog
Don't pay for royalty free images. They are free after all! I offer links to 96 websites that have tens of thousands (maybe even hundreds of thousands) of absolutely free images, including ones for commercial use! All you need to do is subscribe to my blog at www.davesinternetmarketing.info/royalty-free-images-free-for-commercial-use/
Re: Buzzom Offers Featured User Options
This is when discovered this great new way to grow your follow list. You can pay between $10 and $100 for the number of times you want to app ar at the top of the list.
Re: Microsoft Test Bounties
I had spent a good deal of my time looking for someone to explain this subject clearly and I have really enjoyed reading your blog posts and I collected a lot of interesting things as well as I done a research on the subject and learn most peoples will agree with your blog.
Re: 10 Ways to Source Great Sales Leads
Hoovers.com, that have contact information for tens of millions of businesses. If necessary, you can work with these companies' research teams to order lists specifically tailored to your organization's sales needs.
Re: Microsoft Test Bounties
To find bugs and showing it to microsoft is quite admirable. Keep blogging more i will appreciate.

u comment, i follow