Send from Alternate E-mail

LadyDi

Registered User.
Local time
Yesterday, 20:58
Joined
Mar 29, 2007
Messages
894
I currently have two e-mail accounts on my computer. One is my default e-mail address with my name on it. The other e-mail account is a generic account with the department name.

I have a database set up to generate and send e-mails to our technicians notifying them when an order they placed gets put on back order. This database could possibly send twenty or thirty e-mails out each time it is run. My manager has requested that the database send the e-mails from the generic e-mail account instead of the default account. That way, when the field replies to the e-mail, they won't bombard my account.

Is there a way to tell the database which e-mail account to send an e-mail from?

I am currently using the below module to send the e-mails:

Option Explicit
Dim appOutlook As Outlook.Application
Dim namespaceOutlook As Outlook.NameSpace
Sub Outlook_SendMail(sEmailAddr As String, sEmailSubj As String, sEmailBody As String, Optional sAttach1 As String, Optional sAttach2 As String)
Outlook_OpenOutlook 'this is a sub further down the page
Dim mailOutlook As Outlook.MailItem
Dim strDoc As String
strDoc = CurrentProject.Path & "\sample.docx"
'if you wish to add an attachment
Set mailOutlook = appOutlook.CreateItem(olMailItem)
With mailOutlook
.Subject = sEmailSubj
.To = sEmailAddr
.Body = sEmailBody 'place text here
If sAttach1 <> "" Then
.Attachments.Add sAttach1 'attach the doc
End If
If sAttach2 <> "" Then
.Attachments.Add sAttach2
End If
' display the email

'.Display
'send the email
.send
End With
Set mailOutlook = Nothing
End Sub

Sub Outlook_OpenOutlook()
' Initialize outlook objects
On Error Resume Next
Set appOutlook = GetObject(, "Outlook.Application")
If Err <> 0 Then
' attempt to start outlook
' Note that this code can be used to start a second instance of outlook
Set appOutlook = New Outlook.Application
Set namespaceOutlook = appOutlook.GetNamespace("MAPI")
Dim folderOutlook As Folder
Set folderOutlook = namespaceOutlook.GetDefaultFolder(olFolderInbox)
' make outlook visible on the desktop
folderOutlook.Display
Else
Set namespaceOutlook = appOutlook.GetNamespace("MAPI")
End If
End Sub
 
Last edited:
Try

mailOutlook.SentOnBehalfOfName = "Blah@Whatever.com"
 
Thank you for the suggestion. I'll give it a try.
 

Users who are viewing this thread

Back
Top Bottom