help with mail sending using outlook

Discussion in 'Visual Basic ( VB )' started by TOC666, May 28, 2008.

  1. TOC666

    TOC666 New Member

    Joined:
    May 28, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hey everyone
    i'm using this code to send mail via outlook

    Code:
    Sub SendMailOutlook(aTo, Subject, TextBody, aFrom)
      
      'Create an Outlook object
      Dim Outlook 'As New Outlook.Application
      Set Outlook = CreateObject("Outlook.Application")
      
      'Create e new message
      Dim Message 'As Outlook.MailItem
      Set Message = Outlook.CreateItem(olMailItem)
      With Message
        'You can display the message To debug And see state
        '.Display
        
        .Subject = Subject
        .HTMLBody = TextBody
        
        'Set destination email address
        .Recipients.Add (aTo)
        If Len(aFrom) > 0 Then .SentOnBehalfOfName = aFrom
        
        'Set sender address If specified.
        Const olOriginator = 0
        'If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
        
        'Send the message
        .Send
      End With
    End Sub
    
    i'm sending mail using active directory the problam is when i send using an inputbox and there are two names in the active directory, i get an error...

    is there any way to check if there are two names in the active directory before sending and letting the user select the person he ment to send it?

    thanks for ur help
     
    Last edited by a moderator: May 28, 2008

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice