Results 1 to 2 of 2
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Change outlook "From" Address

    I have the below code to send out an email. How do I go about setting the From Account/Address?

    Code:
    Function funSendEmail(strEmailAddr As String, strBody As String, strHeader As String, strFooter As String, strSubject As String)
    On Error GoTo ErrorHandler
        Dim objOutlook As Outlook.Application
        Dim objAccount As Outlook.Account
        Dim objOutlookAttach As Outlook.Attachment
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strAddress As String
        
        Set objOutlook = New Outlook.Application
        Set OutMail = objOutlook.CreateItem(0)
        
        OutMail.To = strEmailAddr
        OutMail.Subject = strSubject
        OutMail.HTMLBody = strHeader & strBody & strFooter
        If gblDisplayEmail Then
            OutMail.Display
        Else
            OutMail.Send  'Send | Display
        End If
        Set OutMail = Nothing
        Exit Function
    ErrorHandler:
        MsgBox "Critical Error!" & vbCrLf & vbCrLf & Err.Description, vbCritical, "Error # " & Err.Number
    End Function


  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Fixed...

    Code:
    Function funSendEmail(strEmailAddr As String, strBody As String, strHeader As String, strFooter As String, strSubject As String)
    On Error GoTo ErrorHandler
        Dim objOutlook As Outlook.Application
        Dim objAccount As Outlook.Account
        Dim objOutlookAttach As Outlook.Attachment
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strAddress As String
        
        Set objOutlook = New Outlook.Application
        Set OutMail = objOutlook.CreateItem(0)
        
        OutMail.SentOnBehalfOfName = "reply@emailaddress.com"
        OutMail.To = strEmailAddr
        OutMail.Subject = strSubject
        OutMail.HTMLBody = strHeader & strBody & strFooter
        If gblDisplayEmail Then
            OutMail.Display
        Else
            OutMail.Send  'Send | Display
        End If
        Set OutMail = Nothing
        Exit Function
    ErrorHandler:
        MsgBox "Critical Error!" & vbCrLf & vbCrLf & Err.Description, vbCritical, "Error # " & Err.Number
    End Function

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

Similar Threads

  1. Using ListBox value as "Body of outlook task"
    By AccessFreak in forum Database Design
    Replies: 3
    Last Post: 05-07-2011, 04:40 PM
  2. "On Change," On Focus"
    By ericsmith in forum Access
    Replies: 0
    Last Post: 03-28-2011, 01:02 AM
  3. change field to "password" type
    By ducecoop in forum Access
    Replies: 3
    Last Post: 11-11-2010, 12:02 PM
  4. How to change the column heading in a "split form"
    By robertrobert905 in forum Forms
    Replies: 1
    Last Post: 09-21-2010, 02:42 PM
  5. Replies: 1
    Last Post: 10-19-2009, 02:37 AM

Tags for this Thread

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