Question regarding OlMailRecipientType.OlTo / olCC / olBCC

  • Thread starter Thread starter Steffen Grellmann
  • Start date Start date
S

Steffen Grellmann

Hi newsgroup,

I want to pass E-Mail-addresses from a Windows form to an
ActiveInspectors CurrentItem. I'm a little bit confused of the
handling of OlMailRecipientType: If I create a new mail item for test
purposes in Example 1, everything is going well. But if I refer to the
CurrentItem of an ActiveInspector (see Example 2) I have to fill the
olTo-Field AFTER the olCC and olBCC fields are filled. Otherwise the
e-mail-addresses are not filled in the correct fields of the
CurrentItem "mail draft" - which is working perfect in Example 1.

As you can see I found a way to handle this behaviour by filling olTo
at last, but I have no idea why this is necessary! Any ideas are
appreciated.

Kind regards,

Steffen

Example 1

Dim objOutlook As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

olNameSpace = objOutlook.GetNamespace("MAPI")
objOutlookMsg =
objOutlook.CreateItem(Outlook.OlItemType.olMailItem)

With objOutlookMsg
objOutlookRecip = .Recipients.Add(EmailTo)
objOutlookRecip.Type = Outlook.OlMailRecipientType.olTo

objOutlookRecip = .Recipients.Add(strCC)
objOutlookRecip.Type = Outlook.OlMailRecipientType.olCC

objOutlookRecip = .Recipients.Add(strBCC)
objOutlookRecip.Type = Outlook.OlMailRecipientType.olBCC
.Display()
End With

Example 2

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

objOutlook = Globals.ThisAddIn.Application
objOutlookMsg = objOutlook.ActiveInspector.CurrentItem

With objOutlookMsg
objOutlookRecip = .Recipients.Add(strCC)
objOutlookRecip.Type = Outlook.OlMailRecipientType.olCC

objOutlookRecip = .Recipients.Add(strBCC)
objOutlookRecip.Type = Outlook.OlMailRecipientType.olBCC

objOutlookRecip = .Recipients.Add(EmailTo)
objOutlookRecip.Type = Outlook.OlMailRecipientType.olTo
End With
 
Back
Top