Results 1 to 2 of 2

Thread: how to send email in vb

  1. #1
    Join Date
    Apr 2011
    Posts
    1

    how to send email in vb

    i need to know how to code sending email when customers create an account, place an order, and change their password. how would i do that in vb. this is a homework assignment and the code i used already works but i need to implement when customers do those three things and send an email that they have created an account, placed an order, and changed their password. how would i do that in this code?

    Try
    Dim Msg As MailMessage = New MailMessage()
    Dim MailObj As New SmtpClient("smtp.mccombs.utexas.edu")
    Msg.From = New MailAddress("littlemic14@yahoo.com", "Michelle Solis")
    Msg.To.Add(New MailAddress("michelle.solis@bba07.mccombs.utexas.edu", "Michelle Solis"))
    Msg.IsBodyHtml = CBool("False")
    Msg.Body = "this is the email body"
    Msg.Subject = "this is the subject"
    MailObj.Send(Msg)
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try

    End Sub

  2. #2
    Join Date
    Feb 2011
    Posts
    117

    Re: how to send email in vb

    Well I want you to just try out the bellow code and see to it whether it helps you or not :

    Code:
     Option Explicit
    
         Private Sub Command1_Click()
           Dim objSession As Object
           Dim objMessage As Object
           Dim objRecipient As Object
    
           'Create the Session Object.
           Set objSession = CreateObject("mapi.session")
    
           'Logon using the session object.
           'Specify a valid profile name if you want to.
           'Avoid the logon dialog box.
           objSession.Logon profileName:="MS Exchange Settings"
    
           'Add a new message object to the OutBox.
           Set objMessage = objSession.Outbox.Messages.Add
    
           'Set the properties of the message object.
           objMessage.subject = "This is a test."
           objMessage.Text = "This is the message text."
    
            'Add a recipient object to the objMessage.Recipients collection.
           Set objRecipient = objMessage.Recipients.Add
    
           'Set the properties of the recipient object.
           objRecipient.Name = "John Doe"  '<---Replace this with a valid
                                           'display name or e-mail alias
           'Type can be ActMsgTo, mapiTo, or CdoTo for different CDO versions;
           'they all have a constant value of 1.
           objRecipient.Type = mapiTo
           objRecipient.Resolve
    
           'Send the message.
           objMessage.Send showDialog:=False
           MsgBox "Message sent successfully!"
    
           'Logoff using the session object.
           objSession.Logoff
         End Sub
    And if you want to get more information on the same then you can click here

Similar Threads

  1. Replies: 4
    Last Post: 23-08-2011, 08:04 AM
  2. Replies: 6
    Last Post: 10-07-2011, 08:26 PM
  3. Replies: 4
    Last Post: 27-02-2011, 04:32 AM
  4. Windows live mail couldn't send email but can receive email
    By danielyen in forum Windows Software
    Replies: 1
    Last Post: 15-07-2010, 12:17 AM
  5. Replies: 2
    Last Post: 14-02-2008, 09:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,534,477.52979 seconds with 17 queries