Results 1 to 2 of 2

Thread: cc email (2003)

  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cc email (2003)

    I am trying to enable my Access database to cc an email recipient if the user chooses.
    My current code is:

    Dim appOutlook As Object
    Dim nms
    Dim pfld
    Dim itms
    Dim rst As Recordset

    Set appOutlook = CreateObject("Outlook.Application")
    Set nms = appOutlook.GetNamespace("MAPI")
    Set pfld = nms.GetDefaultFolder(olFolderOutbox)
    Set itms = pfld.Items


    Set itm = itms.Add("IPM.Note")

    With itm
    .Body = strMSG '& vbcrlf & vbcrlf & strSign
    .Subject = strSubject
    .To = strWHERE


    If IsNull(Me.CC) Then 'This is the combo box where someone would select a cc recipient. If none is selected then bypass the cc option
    Else
    strCC = [Forms]![Phone]![CC].Column(4) 'column 4 contains the email address. When I add the code msgbox strCC after this line it returns the email address
    .CC = strCC
    End If

    outl3:
    .Send
    End With

    Now strcc contains the selected email address but it isn't being sent to the cc address.
    Can someone tell me what I'm doing wrong here?

    Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: cc email (2003)

    The code itself is correct, so perhaps the contents of strCC is incorrect. Are you sure you want Column(4)? This is the 5th column of the combo box, for counting starts at 0.

    Note: you can replace

    Set nms = appOutlook.GetNamespace("MAPI")
    Set pfld = nms.GetDefaultFolder(olFolderOutbox)
    Set itms = pfld.Items
    Set itm = itms.Add("IPM.Note")

    with the shorter

    Set itm = appOutlook.CreateItem(0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •