1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help with mail sending using outlook

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

  1. TOC666

    TOC666 New Member

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

    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
        .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
      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