CC on E-mail with MAPI ocx's..

This is probably an easy answer but I've never done it before. With the E-mail ocx's provided with VB6, MAPIMessages and MAPISession, is there a way to specify who the message get's CC:'ed to? I know to specify the recipdisplayname property, but is there a property for CCing to other E-mail addresses?
Who is Participating?
Here is something that I use to send to multiple people that are passed in from the command line (; delimited):

Public Function SendAsEmail()

  Dim Counter As Long
  Dim NumberOfRecips As Long
  NumberOfRecips = GetNumberOfRecips(gMail)
  EMail.MAPISession1.UserName = "Name"
  EMail.MAPISession1.Password = "PASS"
  EMail.MAPISession1.LogonUI = False
  EMail.MAPISession1.NewSession = True
  EMail.MAPIMessages1.SessionID = EMail.MAPISession1.SessionID
  EMail.MAPIMessages1.MsgSubject = "ArcServe Tape Rotation!!"
  EMail.MAPIMessages1.MsgNoteText = " "
  EMail.MAPIMessages1.AttachmentIndex = 0
  EMail.MAPIMessages1.AttachmentPathName = gPath
  EMail.MAPIMessages1.AttachmentPosition = 0
  EMail.MAPIMessages1.AttachmentType = mapData
  Dim Receip As String
  For Counter = 0 To NumberOfRecips
     EMail.MAPIMessages1.RecipIndex = Counter
     EMail.MAPIMessages1.RecipType = mapToList
     EMail.MAPIMessages1.RecipDisplayName = GetRecipName(gMail, Counter + 1)
     EMail.MAPIMessages1.AddressResolveUI = True
  Next Counter
End Function

Public Function GetRecipName(ByVal RecipList As String, ByVal WhichRecip As Long) As String

  Dim CurrentRecip As Long
  Dim SemiColonPosition As Long
  Dim LastSemiColonPosition As Long
  Dim CurrentRecipName As String
  LastSemiColonPosition = 1
  SemiColonPosition = 0
  CurrentRecip = 0
  If Right(RecipList, 1) <> ";" Then
    RecipList = RecipList & ";"
  End If
    SemiColonPosition = InStr(LastSemiColonPosition, RecipList, ";", 1)
    If SemiColonPosition <> 0 Then
      CurrentRecipName = Mid(RecipList, LastSemiColonPosition, SemiColonPosition - LastSemiColonPosition)
      CurrentRecip = CurrentRecip + 1
      LastSemiColonPosition = SemiColonPosition + 1
    End If
  Loop While CurrentRecip < WhichRecip
  GetRecipName = CurrentRecipName
End Function

provb6dbAuthor Commented:
Thanks alot, I figured it was something similar to that, but didn't know what to write in the code. Your help was great!
provb6dbAuthor Commented:
Ok, so now for the code I write .recipdisplayname = SendasEmail(.recipdisplayname) ??
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

provb6dbAuthor Commented:
Oh, and do you know how to bold only certain parts of messagebox text?
(I'll give you more points if you do.)

provb6dbAuthor Commented:
I'm getting an arguement not optional error. DId you forget to include code for a "GetNumberOfRecips" function? or did you mispell in your code?
Sorry about that, here is that function:

Public Function GetNumberOfRecips(ByVal RecipList As String) As Long

  Dim RecipCount As Long
  Dim SemiColonPosition As Long
  SemiColonPosition = 0
  RecipCount = 0
    SemiColonPosition = InStr(SemiColonPosition + 1, RecipList, ";", 1)
    If SemiColonPosition <> 0 Then
      RecipCount = RecipCount + 1
    End If
  Loop While SemiColonPosition <> 0
  GetNumberOfRecips = RecipCount
End Function
provb6dbAuthor Commented:
Could you explain just a little to me how this works? Where do I specify to use the SendasEmail function?

Here's my code for sending the E-mail. It doesn't find any recipients.I edited out any of the code in the functions that duplicated what I had already done, like signing on, etc.


    With MAPIMessages1
        .MsgIndex = -1
        EmailAddress$ = Trim(tbxRecipAddress.Text)
        If Trim(tbxRecipAddress.Text) <> "" Then
            .RecipDisplayName = SendAsEmail(Trim(tbxRecipAddress.Text))
            MsgBox "Enter destination E-mail address.", vbOKOnly, "No E-mail address"
            Exit Sub
        End If
        .MsgSubject = Trim(tbxSubject.Text)
        .MsgNoteText = Trim(tbxMessage.Text)
        If Attachment = True Then
            .AttachmentName = FileName
            .AttachmentPathName = FilePathName
        End If
'        .SessionID = MAPISession1.SessionID
'        .Send
'        MAPISession1.SignOff
    End With

Any ideas?


provb6dbAuthor Commented:
Could you please explain a little how this works? If you have any variables that should be changed to the variable names I have please let me know. I don't understand what this is supposed to do yet.

Did you change SendAsEmail go take a string variable?

gMail is a global variable that is set from the command line in my program, so either change SendAsEmail() to be SendAsEmail(ByVal gMail As String) or before you call SendAsEmail set gMail to your string.
provb6dbAuthor Commented:
Thanks, i get how it works now. Thanks for the help. It works great!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.