Results 1 to 5 of 5
  1. #1
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    215

    SendEmail CC

    I have the following code, which works perfectly to send an email.
    Code:
    Private Sub Yes_Click()
    On Error GoTo SendEmail_Err
        Dim myOlApp As Object
        Dim myNameSpace As Object
        Dim myFolder As Object
        Dim myItem As Object
        Dim myAttachments, myRecipient As Object
        Dim recipient As String
        Dim file_name As String
        Dim mySubject As Object
        Dim dbs As Object
        Dim rst As Object
        Dim strSQL As String
        
        strSQL = "EmailSendExpDate"
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset(strSQL)
        rst.MoveFirst
        While Not rst.EOF
            recipient = rst![Business Email Address]
            Set myOlApp = CreateObject("Outlook.Application")
            Set myItem = myOlApp.CreateItem(olMailItem)
            Set myAttachments = myItem.Attachments
            Set myRecipient = myItem.Recipients.Add(recipient)
            '"Message Subject String Here"
            myItem.Subject = "Upcoming Renewal/Expiration Date"
            '"Put Message Body Text Here"
            myItem.Body = 'enter the text here    
            myItem.Display
            rst.Edit
            rst!Emailed = True
            rst!EmailedDate = Date
            rst.Update
            rst.MoveNext
        Wend
        DoCmd.Close acForm, "EmailSendNotification"
        Set myRecipient = Nothing
        Set myAttachments = Nothing
        Set myItem = Nothing
        Set myOlApp = Nothing
        Set rst = Nothing
    SendEmail_Exit:
        Exit Sub
    SendEmail_Err:
        MsgBox Err.Description
        Resume SendEmail_Exit
    End Sub
    My problem occurs when I go to add a CC to the email. I have tried the following:
    Code:
    Set myRecipient = myItem.Recipients.Add(recipient)
    Set myRecipient = myItem.Recipients.Add("abc@123.com" & "; " & "abc@def.com")
    myRecipient.Type = olCC
    I have this exact code in a sample database and it adds the CC's perfectly but when I try it in the actual db it doesn't add the CC's at all. I don't get any errors, so I don't know why it's not working.



    Is this the proper/most effective way to add a CC to my email? I found this solution at: http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Try:

    myItem.CC = "abc@123.com; abc@def.com"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    215
    That worked. Thanks.

    Do you have any idead as to why it would work in one db and not the other? This question is just for my peace of mind.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Not offhand. You might try a different variable for the CC recipients.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    215
    Ok, not that big of a deal. Thanks anyway.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. AfterUpdate SendEMail Macro
    By gdgonzal in forum SharePoint
    Replies: 3
    Last Post: 04-13-2012, 01:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums