October 2009
M T W T F S S
    Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

Archives

Categories

  • [+]ASP.NET (7) 
  • [+]C# (87) 
  • [+]C++ (13) 
  • [+]Delphi (20) 
  • [+]JavaScript (24) 
  • [+]Regular Expressions (7) 
  • [+]SQL (13) 
  • [—]VB (100) 
  • [+]VB.NET (4) 

Online

Users: 8 Guests
  • Loading...


    Loading...

    Login






    Register | Lost password?

    Register





    A password will be mailed to you.
    Log in | Lost password?

    Retrieve password





    A confirmation mail will be sent to your e-mail address.
    Log in | Register
  • Send Email from Visual Basic Using OLE Messaging

    ' ----------------------------------------------------
    ' Notes :
    '
    ' On the Tools menu, choose References and select the
    ' Microsoft CDO 1.21 Library
    ' ----------------------------------------------------
    
    ' ----------
    ' Code
    ' ----------
    
    Private Sub Send_Email(Subject As String, MessageText As String, RecipientName As String)
      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 = Subject
      objMessage.Text = MessageText
    
      'Add a recipient object to the objMessage.Recipients collection
      Set objRecipient = objMessage.Recipients.Add
    
      'Set the properties of the recipient object
      objRecipient.Name = RecipientName
    
      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
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    1 comment to Send Email from Visual Basic Using OLE Messaging

    Leave a Reply

     

     

     

    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">

    Spam Protection by WP-SpamFree Plugin