none
Sending email via MS Access - problems using CC and/or BCC RRS feed

  • Question

  • I am new to this coding business.  I have search and tried so many ways to fix this in the last week - I am exhausted!  Please help! Please provide simple asnwer; do not  assume I will know where codes need to be inserted.

    Please provide full coding as it must be inserted in the Event Procedure.

     

      I am trying simply to send an email from a form.  I am using the following Event but it returns Error 94 - which I have searched and searched and found no solution I can understand.


    Private Sub SendEmail_Click()
    On Error GoTo ProcErr

        Dim stLinkCriteria As String
        Dim stCC As String
        Dim stSubject As String
        Dim stMessage As String
       
    stLinkCriteria = Me![MessageTo]
    stCC = Me![EmailCC]
    stBCC = Me![EmailBCC]
    stSubject = Me![EmailSubject]
    stMessage = Me![EmailMessage]


    DoCmd.SendObject acSendNoObject, , , stLinkCriteria, , stCC, stBCC, stSubject, stMessage

    ProcExit:
    Exit Sub

    ProcErr:
    If Err.Number = 2501 Then
        GoTo ProcExit
    End If
    MsgBox "Error#" & Err.Number & "." & Err.Description & "- SendEmail_Click"
        Resume ProcExit
    End Sub

     

    THANK YOU in advance for any help you may be able to provide.

    Wednesday, April 11, 2007 1:31 AM

All replies

  • One of these posts is probably enough... mods please delete the duplicates? Smile
    Wednesday, April 11, 2007 11:35 AM
  • I only posted this once and it seems to be there multiple times... I am new to this forum and don't know what could have happened.

     

    Val

    Wednesday, April 11, 2007 12:46 PM
  • I don't know what's wrong with your code. But here is the code I am using. Maybe this helps. I am using some shared variable here, so you need to change it to your own stuff.

     

     

    Private Sub OneEmail(EmailAddress As String, emailBody As String)
        ' Create the message.
        Dim objOutlookMsg As Outlook.MailItem
        Dim objOutlookRecip As Outlook.Recipient
        Set objOutlookMsg = ObjOutlook.CreateItem(olMailItem)
        With objOutlookMsg
            ' Add the To recipient(s) to the message.
            Set objOutlookRecip = .Recipients.Add(EmailAddress)
            objOutlookRecip.Type = olTo
            '.BCC = "testing@hotmail.com"
    '        .SentOnBehalfOfName = "testing@support.com"
            
            ' Set the Subject, Body, and Attachment.
            .Subject = "your order processed from " + _
                Format(FromDate, "mm-dd-yyyy") + " to " + Format(ToDate, "mm-dd-yyyy")
            .HTMLBody = emailBody
            .Attachments.Add shareAttachmentName
           
            ' Resolve recipient's name.
            objOutlookRecip.Resolve
           
    '        .Display
            .Save
    '        .Send
        End With
    End Sub

    Wednesday, April 11, 2007 10:04 PM