Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Outlook Newsgroups
Outlook VBA Programming
Redemption/Outlook cant set recipient types!!
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="amarmaj, post: 4861923"] Somebody please indulge me! I'm tearing my hair out at trying to set the TO and CC recipient types using the function below. If I have just one name in the TO and one in the CC all works well. However if I have multiple entries in the CC field (passed in as a ; separated list), when the mail is received by the various recipients, the TO and CC are all messed up and not as in the TO and CC fields as I had sent them. I've tried various ways of setting the TO and CC types eg SafeItem.Recipients.Item(0).Type = SafeItem.Recipients.Item(0).Type = olCC ' SafeItem.Recipients.Item(0).Type = Outlook.OlMailRecipientType.olCC ' SafeItem.Recipients.Item(0).Type = olCC but to no joy. I'm sure I am probably missing something quite simple. ps using Outlook 2003 on Win XP Pro SP2 thanks for any help Amar Function SendSafeMail(sTO As String, sSubject As String, sBody As String, Optional sAttachment As String, Optional sCC As String) As Boolean '****************************************************** 'Name: SendSafeMail ' 'Purpose: Sends email. Uses Outlook application to login to default profile, ' then uses Redemption to send mail in order to avoid ' Oulook security prompts ' 'Inputs: to,subject,body,attachment,cc ' 'Returns: boolean '********************************************************** On Error GoTo ErrHandler Dim ouApp As Outlook.Application Dim ouNS As Outlook.NameSpace Dim SafeItem As Redemption.SafeMailItem Dim oItem As Object Dim arrTORecipients() As String Dim arrCCRecipients() As String Dim i As Integer Set ouApp = CreateObject("Outlook.Application") Set ouNS = ouApp.GetNamespace("MAPI") ouNS.Logon 'login using default user credentials Set SafeItem = CreateObject("Redemption.SafeMailItem") Set oItem = ouApp.CreateItem(0) 'new message SafeItem.Item = oItem SafeItem.Subject = sSubject SafeItem.Body = sBody If Len(sAttachment) <> 0 Then SafeItem.Attachments.Add (sAttachment) End If 'see if there is more than one TO recipient If InStr(1, sTO, ";") > 0 Then arrTORecipients() = Split(sTO, ";") For i = 0 To UBound(arrTORecipients) 'add all the recipients to TO list SafeItem.Item = oItem SafeItem.Recipients.Add arrTORecipients(i) SafeItem.Recipients.Item(0).Type = SafeItem.Recipients.Item(0).Type = olTO 'SafeItem.Recipients.Item(0).Type = Outlook.OlMailRecipientType.olTO 'SafeItem.Recipients.Item(0).Type = olTO Next i Else 'just one recipient SafeItem.Item = oItem SafeItem.Recipients.Add (sTO) SafeItem.Recipients.Item(0).Type = SafeItem.Recipients.Item(0).Type = olTO 'SafeItem.Recipients.Item(0).Type = Outlook.OlMailRecipientType.olTO 'SafeItem.Recipients.Item(0).Type = olTO End If If Len(sCC) <> 0 Then 'see if there is more than one CC If InStr(1, sCC, ";") > 0 Then arrCCRecipients() = Split(sCC, ";") For i = 0 To UBound(arrCCRecipients) 'add all the recipients to TO list SafeItem.Item = oItem SafeItem.Recipients.Add arrCCRecipients(i) SafeItem.Recipients.Item(0).Type = SafeItem.Recipients.Item(0).Type = olCC ' SafeItem.Recipients.Item(0).Type = Outlook.OlMailRecipientType.olCC ' SafeItem.Recipients.Item(0).Type = olCC Next i Else SafeItem.Item = oItem SafeItem.Recipients.Add (sCC) SafeItem.Recipients.Item(0).Type = SafeItem.Recipients.Item(0).Type = olCC ' SafeItem.Recipients.Item(0).Type = Outlook.OlMailRecipientType.olCC ' SafeItem.Recipients.Item(0).Type = olCC End If End If SafeItem.Recipients.ResolveAll SafeItem.Send SendSafeMail = True ExitPoint: On Error Resume Next Set ouApp = Nothing Set ouNS = Nothing Set oItem = Nothing Set SafeItem = Nothing Exit Function ErrHandler: SendSafeMail = False Resume ExitPoint End Function [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Outlook Newsgroups
Outlook VBA Programming
Redemption/Outlook cant set recipient types!!
Top