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?
provb6dbAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

twardCommented:
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.MAPISession1.SignOn
 
  EMail.MAPIMessages1.SessionID = EMail.MAPISession1.SessionID
 
  EMail.MAPIMessages1.Compose
 
  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
     EMail.MAPIMessages1.ResolveName
 
  Next Counter
 
  EMail.MAPIMessages1.Send
  EMail.MAPISession1.SignOff
 
  End
 
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
 
  Do
   
    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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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) ??
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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

Jason
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?
twardCommented:
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
 
  Do
 
    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.

    MAPISession1.SignOn

    With MAPIMessages1
        .MsgIndex = -1
       
        EmailAddress$ = Trim(tbxRecipAddress.Text)
       
        If Trim(tbxRecipAddress.Text) <> "" Then
            .RecipDisplayName = SendAsEmail(Trim(tbxRecipAddress.Text))
        Else
            MsgBox "Enter destination E-mail address.", vbOKOnly, "No E-mail address"
            tbxRecipAddress.SetFocus
            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?

Jason

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.

Jason
twardCommented:
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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.