Respond to Outlook Email

MEG_AGI

New Member
Outlook version
Outlook 2019 64-bit
Email Account
Office 365 Exchange
Using VBA within Access, I'm trying to reply to an email with a template. The code follows and it creates and displays the email that I want.

However, it doesn't show the SEND button on the email.

The subroutine performs a .display to show the email. Do I need to use a different command?

' Email Response
'
' Parameters
' Template for reply
' Email Box to find Email
' Email Address to Respond


Sub srtnGenerateReply(ByVal sTemplateText As String, ByVal sEmailMailBox As String, ByVal sEmailAddress As String)

Dim OutlookApp As outlook.Application
Dim OutlookNamespace As outlook.NameSpace
Dim olShareName As outlook.Recipient
Dim Folder As MAPIFolder
Dim olItems As outlook.Items
Dim OutlookMail As Variant
Dim arrResults() As Variant
Dim ItemCount As Long


Dim sFilter As String

sFilter = "[SenderEmailAddress] = '" & sEmailAddress & "'"


Set OutlookApp = New outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set olShareName = OutlookNamespace.CreateRecipient(sEmailMailBox)
Set Folder = OutlookNamespace.GetSharedDefaultFolder(olShareName, olFolderInbox)
Set olItems = Folder.Items.Restrict(sFilter)




' sort to get the most recent email for the Email Address to respond
olItems.Sort "[ReceivedTime]", True

If olItems.Count < 1 Then
MsgBox ("No Email Found")
End If


For Each OutlookMail In olItems


OutlookMail.ReplyAll

OutlookMail.HTMLBody = sTemplateText & _
" <hr> <br/>" & _
"<b>From: </b>" & OutlookMail.SenderName & " [" & OutlookMail.SenderEmailAddress & "]<br/>" & _
"<b>Sent: </b>" & OutlookMail.SentOn & "<br/>" & _
"<b>To: </b>" & OutlookMail.To & "<br/>" & _
"<b>Subject: </b>" & OutlookMail.Subject & "<br/>" & _
"<br/>" & _
OutlookMail.HTMLBody\

OutlookMail.Display

Exit For ' Exit -- Only reply to lastest email

Next OutlookMail




Set OutlookApp = Nothing
Set OutlookNamespace = Nothing

End Sub
 
Similar threads
Thread starter Title Forum Replies Date
M Outlook 2007 won't respond? Using Outlook 3
B Vba to monitor time to respond to emails using a shared mailbox Outlook VBA and Custom Forms 5
K CommandButton1 does not respond Outlook VBA and Custom Forms 1
K why is a user getting email respond for invite respond that she didn't set up. Using Outlook 3
P Outlookslow to respond Using Outlook 1
A Issue with respond to an email message with a meeting request Using Outlook 0
P email arrows - respond and forward Using Outlook 1
M ItemEvents_10_OpenEventHandler does not respond on DocumentItems Outlook VBA and Custom Forms 2
I Button PDF in Outlook Contact custom form Outlook VBA and Custom Forms 0
G VBA to save selected Outlook msg with new name in selected network Windows folder Outlook VBA and Custom Forms 1
X Outlook automation pull from PDF Using Outlook 5
O Outlook 365 - How to create / copy a new contact from an existing one? Using Outlook 3
M Gmail address associated with Outlook on new phone Using Outlook 9
D Cannot populate certain UserProperties in Outlook from Excel Outlook VBA and Custom Forms 1
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
G Outlook 2016: Want IMAP Data Files on My D: Drive and Not C: Drive Using Outlook 1
V Validating Outlook form with "OR" and "AND" Outlook VBA and Custom Forms 1
D Outlook 2016 64bit, Cannot Save in 'HTML', format Using Outlook 1
J Connect outlook to office365 exchange _without_ signing in office apps Using Outlook 4
D Outlook launch email showing new unread email in reading pane Using Outlook 11
M Convertor for Outlook Express Mail Store (.dbx) to Outlook Mail Store (.pst) Using Outlook 0
K Outlook adds space to rows in HTML email signatures viewed on mobile Using Outlook 1
L Outlook 2010 Outlook 2010 Outlook VBA and Custom Forms 2
V Outlook behaving oddly Using Outlook 2
M HTML email signature in Outlook Using Outlook 1
C What folders are needed when reinstalling Outlook 2010 Using Outlook 0
P Color Code or highlight folders in Outlook 2016 Using Outlook 2
U Outlook locking up when replying to Email Using Outlook 7
J Outlook Autocomplete (Recipients) opens upward Using Outlook 2
A "Get Add-Ins" - Which Version of Outlook to use Using Outlook 1
O Newbie question: how to sync two Outlook -Exchange and IMAP- calendars? Using Outlook 4
P Syncing Outlook & iPhone Calendars Using Outlook 4
S Unable to extract text from an Outlook email message Using Outlook 2
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
T Outlook creates a copie of every mail I send Using Outlook.com accounts in Outlook 4
O Outlook - hidden contacts? Using Outlook 2
F Outlook 365 is "Possessed" Using Outlook 2
e_a_g_l_e_p_i Can someone explain syncing with Outlook and Gmail Using Outlook 3
K Outlook Office 365 VBA download attachment Outlook VBA and Custom Forms 2
e_a_g_l_e_p_i Gmail in Outlook 2010 preview issue Using Outlook 4
I Outlook is stuck at "Updating Calendar" Using Outlook 1
AmonRa Outlook 365 calendar - too much white space Using Outlook 0
e_a_g_l_e_p_i Outlook 2010 Help setting up Gmail account in Outlook 2010 Using Outlook 3
C-S-R How to clear an Outlook (To Do) Task Flag? Using Outlook 8
N How do I make Outlook autocomplete addresses from a list of recognised <full_names> only? Using Outlook 2
P Outlook 2019 UI changes after 20H2 update Using Outlook 1
R How to restrict GWSMO sync to Outlook Send/Receive cycles Using Outlook 0
B Outlook 2016 Unable to view images or logos on the outlook 2016 emails the same html code works well when i use outlook 2010 Using Outlook 0
S Outlook 2007 crash linked to gdiplus.dll Using Outlook 0
P Sending email from outlook IMAP to GMAIL where embedded images are added as attachment Using Outlook 1

Similar threads

Top