I have an Access database that I send out emails to our customers. When the command button is selected it opens Microsoft Office and generates the emails for me to send. We have now created a general email address (like info@abccompany.com) that is shared among my team. It is possible to change the from address in Outlook for the emails generated from Access? So instead of being from my email address, they are from the general email address?
Thank you
8 20918
I have moved your thread from General to the Access/VBA forum which will hopefully get a more focused response.
There are several methods for sending emails from Access. Which method are you using?
For example, I use CDO to send emails and that allows me to specify the send address. Any valid email address can be used.
I have an example database illustrating this approach. See CDO EMail Tester
I am using VB code to send out the emails from Outlook with Access. Below is a bit of my code regarding the emails and attachments. - Do While Not rs.EOF '
-
temp = rs("AGENT")
-
MyFileName = rs("AGENT")
-
-
attach = mypath & MyFileName & ".pdf"
-
strEMail = rs![email] & ";"
-
'
-
DoCmd.OpenReport "R1099", acViewReport, , "[AGENT]='" & temp & "'"
-
DoCmd.OutputTo acOutputReport, "", acFormatPDF, attach
-
DoCmd.Close acReport, "R1099"
-
DoEvents
-
'
-
With oMail
-
.To = Left$(strEMail, Len(strEMail) - 1)
-
.Body = "With the end of 2022 approaching, we are looking to get a jump on year end 1099 preparation. Please review the attached information and let us know if any corrections are required." & vbCrLf & "Thanks," & vbCrLf & "Accounting"
-
.Subject = MyFileName & " Tax Information"
-
.Attachments.Add attach
-
.Display
-
End With
I have permissions to a shared email address with others in the office. I would like the emails I am sending to come from that email address instead of my email address.
Thanks,
zmbd 5,501
Expert Mod 4TB
Good morning kjhyder;
There is an obj.SendUsingAccount function - I've not used it myself in the Access environment; however, I have used it in the Outlook environment ( Microsoft Function: outlook.mailitem.sendusingaccount ) I'm sure there's a way to use this in the Access VBA - might have to either late-bind or add the reference to the Microsoft Outlook object library.
I'll see if I can bodge something together in a little bit - may be Monday as the code I've used is on my work-account-desktop so I don't have access (punny :) ) to it right now.
>> keep in mind however, that the original sender information is pegged to the email; thus, while it may appear that it was sent directly from the secondary account (the uninformed user will not know/see any difference), the account that is associated with the primary outlook client is still in the email headers - this is an anti-spam/malware feature and there is no easy way around this within the Outlook/Office-VBA environment.
zmbd 5,501
Expert Mod 4TB
Good morning kjhyder;
Any progress on your end using the information I provided earlier?
Mind posting any progress you've made?
I do have my code:
1) You must have the desktop client installed. The code will not work with the cloud-based-outlook web-application.
Several of my remote labs have Outlook thru our company's Office365 tenant subscription; however, they do not have the desktop Outlook application installed on their local PCs which has created an issue or two for us (seems you have to pay for more "seats" and the company doesn't want to do that right now 😢 )
2) The account you want to use must be added to the desktop client
(Link to instructions: Add an email account to Outlook ) there is simply no other way to do this unless you have the account already setup
3) I can verify that the resulting email headers have your user account information included in one of the lines; thus, while it will appear for all intents and purposes to come from the chosen account, with the replyto set for that account, anyone with the knowledge how to read the message header information can trace the email right back to your exact PC if needed... Caveat emptor
If the General EMaIL Account ( info@abccompany.com) exists in your Accounts Collection, then the following should work (basic Code): -
Dim OutApp As Object
-
Dim objAccount As Object
-
Dim objMail As Object
-
Dim intCtr As Integer
-
-
Set OutApp = CreateObject("Outlook.Application")
-
-
For intCtr = 1 To OutApp.Session.Accounts.Count
-
If OutApp.Session.Accounts.Item(intCtr) = "info@abccompany.com" Then
-
Set objAccount = OutApp.Session.Accounts.Item(intCtr)
-
Set objMail = OutApp.CreateItem(0)
-
With objMail
-
.Subject = "Some Subject"
-
.Body = "Body Text here"
-
.To = "someone@somewhere.com"
-
.SendUsingAccount objAccount
-
.Send
-
End With
-
End If
-
Next
-
zmbd 5,501
Expert Mod 4TB
Hello ADezii
Remarkably similar to the code I have except I look for the SMTP address directly. - Option Compare Database
-
Option Explicit
-
-
Sub SendUsing_LateBindMethod_Click()
-
'Use following Dim statements for Late Binding
-
'NOTE: Additional Const declaration
-
Const olMailItem As Long = 0 'For Late Binding
-
Const olFolderInbox As Long = 6 'For Late Binding
-
Const olFormatHTML As Long = 2 'For Late Binding
-
Dim objOutlook As Object 'Outlook.Application '(Note dimensioned as Object)
-
Dim objEmail As Object 'Outlook.MailItem '(Note dimensioned as Object)
-
Dim objNameSpace As Object 'Outlook.NameSpace '(Note dimensioned as Object)
-
Dim objFindAccount As Object 'Outlook.Account Temporary object to find the correct account object
-
Dim strFromSmtpAddress As String
-
Dim strSubject As String
-
Dim strToAddress As String
-
Dim strBodyText As String
-
-
On Error GoTo zErrorTrap
-
'
-
' Just a place to put this information
-
strSubject = "My Test Message - testing sendusingaccount property"
-
strToAddress = "BogusToEmail@TrashMail.com"
-
strFromSmtpAddress = "BogusSMTPEmail@TrashMail.com"
-
strBodyText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
-
'
-
' Late bind to the outlook application - may not work for Outlook365 - must have desktop version
-
Set objOutlook = GetObject(, "Outlook.Application")
-
'
-
' Hook to the currently running outlook application session or create a new session
-
If objOutlook Is Nothing Then
-
Set objOutlook = CreateObject("Outlook.Application")
-
Set objNameSpace = objOutlook.GetNamespace("MAPI")
-
objNameSpace.GetDefaultFolder(olFolderInbox).Display
-
End If
-
'
-
' Create a new mail item
-
Set objEmail = objOutlook.CreateItem(olMailItem)
-
'
-
' Find the SMPT account in the curent session that you want to send from if not the default account
-
If Len(strFromSmtpAddress) > 0 Then
-
For Each objFindAccount In objOutlook.Session.Accounts
-
If objFindAccount.SmtpAddress = strFromSmtpAddress Then
-
Set objEmail.SendUsingAccount = objFindAccount
-
End If
-
Next
-
End If
-
'
-
' Start the email and send (note there are alot of options here - this are the basics)
-
With objEmail
-
.To = strToAddress
-
.Subject = strSubject
-
.BodyFormat = olFormatHTML
-
.Body = strBodyText
-
'
-
'uncomment to show the email and allow the user to edit before sending.
-
.Display
-
'
-
'comment out display to send without visual
-
'.Send
-
'
-
End With
-
'
-
'clean up the memory
-
zRecover:
-
If Not objFindAccount Is Nothing Then Set objFindAccount = Nothing
-
If Not objOutlook Is Nothing Then Set objOutlook = Nothing
-
If Not objEmail Is Nothing Then Set objOutlook = Nothing
-
If Not objNameSpace Is Nothing Then Set objOutlook = Nothing
-
Exit Sub
-
zErrorTrap:
-
'Stop
-
Select Case Err.Number
-
Case 429
-
'no current outlook object resume the code and create an object
-
Resume Next
-
Case Else
-
MsgBox "ErrSource: " & Err.Source & vbCrLf & "ErrNum: " & Err.Number & vbCrLf & "ErrDescription: " & vbCrLf & Err.Description
-
End Select
-
Resume zRecover
-
End Sub
-
Thank you both for the assistance. I will input the code changes and test.
How do I send an email from a different email address?
Step 1: Add an address you own, online payment gateway in uae,
On your computer, open Gmail.
In the top right, click Settings. ...
Click the Accounts and import or Accounts tab.
In the "Send mail as" section, click Add another email address.
Enter your name and the address you want to send from.
Click Next Step.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tanya |
last post by:
Running a PHP mail script on Linux which has Exchange as the mail
server.
The script does not send mail to any internal email address but sends
it to any other address outside its domain!
Can...
|
by: acni |
last post by:
I have the following peice of code to try and send an email to selected
contacts in my form.The problem is this line:
StrStore = DLookup("", "qrySelectEmail", "??????")
This looks up the email...
|
by: Eduardo Rosa |
last post by:
Somebody knows how I queue email using .Net?
thanks a lot
|
by: Jim in Arizona |
last post by:
I've made an application that is a computer problems (tickets) system. The
employee goes to a web page and posts the comptuer problem they're having.
Then, the IS staff goes to another webpage...
|
by: Mose |
last post by:
Greetings! I am using Access '97 to track company orders. It's a pretty
basic setup featuring a main table (tbl_SalesSlip) and a related table
(tbl_ModelsSold). I would like to send an email that...
|
by: moondaddy |
last post by:
I have some code in a web app (asp.net 2.0) and am trying to send an email
to 2 different recipients. The first one works and the second one fails.
the first email address is of the same domain as...
|
by: gyap88 |
last post by:
I am currently using vb 2005. I have 3 columns in my database. One containing all the email address,another containing usernames, another containing password.
My program has this button whereby...
|
by: Drewman626 |
last post by:
Can anyone tell me how to either create a doubleclick event or a command button that will start an MS Outlook email (default client) to the ContactEmail1 control?
I cannot figure out how to start...
|
by: shansivamani |
last post by:
using SMTP to send email.
is there any settings need to be configured apart from Host name and
Port, while sending emails using SMTPClient in .Net?
when i try to send mail to ids which has only...
|
by: Jose Olide |
last post by:
I'm attempting to do some simple lead form logic with PHP Mailer.
I need to send mail to several different email addresses conditioned by the email's subject line or if possible, several...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |