none
Sending Outlook email w/ alt email account and sig block RRS feed

  • Question

  • I have inherited a task.
    Any of three different workers can enter data for a job into Access and it
    creates an email response to go back to the prospect customer.

    It works. The problem is that the email then bears the 'From' field as any
    of these different workers.

    They would like there to be a generic signature block that could be appended
    instead of their usual one.

    Here is some of the code below:

        Dim CC_email As String
        Dim BCC_email As String
        Dim Subject_email As String
        Dim Body_email As String

        Dim lngClientContactID As Long
        Dim strClientEmailAddress As String
        Dim strAcknowledgementPdfPath As String

        On Error GoTo Err_SendAckMessage

        If Not IsNull(Forms!frmCase.Form.cboContactID_Client.Column(0)) Then
            lngClientContactID =
    Forms!frmCase.Form.cboContactID_Client.Column(0)
            strClientEmailAddress = Nz(DLookup("emailAddress", "tblContact",
    "contactID = " & lngClientContactID), "")
        Else
            MsgBox "No client contact has been chosen."
        End If

        strAcknowledgementPdfPath = DLookup("caseFolderLocation",
    "tsysReference")

        If Right(strAcknowledgementPdfPath, 1) <> "\" Then
            strAcknowledgementPdfPath = strAcknowledgementPdfPath & "\" &
    strQuoteNbr & "\" & strQuoteNbr & "_Acknowledgement.pdf"
        Else
            strAcknowledgementPdfPath = strAcknowledgementPdfPath & strQuoteNbr
    & "\" & strQuoteNbr & "_Acknowledgement.pdf"
        End If

        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset("tsysReference")
        ' Populate Recordset object.

        rst.MoveLast
        rst.MoveFirst

        On Error Resume Next

        With rst
            CC_email = !AckccEmailAddress
            BCC_email = !AckbccEmailAddress
            Subject_email = !AckEmailSubject
            Body_email = !AckEmailBody
        End With

        rst.Close
        On Error GoTo 0
        Set dbs = Nothing

        On Error GoTo 0
        ' Create the Outlook session.
        Set objOutlook = CreateObject("Outlook.Application")

        ' Create the message.
        Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

        With objOutlookMsg
            If strClientEmailAddress <> "" Then
                Set objOutlookRecip = .Recipients.Add(strClientEmailAddress)
                objOutlookRecip.Type = olTo
            End If

            ' Add the CC recipient(s) to the message.
            If CC_email = "" Then GoTo DoBcc
            Set objOutlookRecip = .Recipients.Add(CC_email)
            objOutlookRecip.Type = olCC

    DoBcc:
            If BCC_email = "" Then GoTo DoSubject

            ' Add the BCC recipient(s) to the message.
            Set objOutlookRecip = .Recipients.Add(BCC_email)
            objOutlookRecip.Type = olBCC

    DoSubject:
            ' Set the Subject, Body, and Importance of the message.
            .Subject = Subject_email
            .Body = Body_email
            .Importance = olImportanceHigh 'High importance

            ' Add attachments to the message.
            'Attachments based on EntryType Public variable
            js = EntryType

            If Not IsMissing(AttachmentPath1) Then
                Set objOutlookAttach = .Attachments.Add(AttachmentPath1)
            Else
                Set objOutlookAttach =
    .Attachments.Add(strAcknowledgementPdfPath)
            End If

            If Not IsMissing(AttachmentPath2) Then
                Set objOutlookAttach = .Attachments.Add(AttachmentPath2)
            End If

            If Not IsMissing(AttachmentPath3) Then
                Set objOutlookAttach = .Attachments.Add(AttachmentPath3)
            End If



    How can I call for a different email account in Outlook to send this email
    rather than the workers default accout.

    I know Outlook allows multiple accounts and you can manually select which
    one to use as a 'Send From'; I just want to automate this.

    Thanks, and if I'm in the wrong area, please point me in the right
    direction.

    DougSix
    Friday, November 30, 2012 1:52 AM

All replies