"New" Outlook

DB Novice
Lounger
Posts: 49
Joined: 14 Jan 2015, 23:04

"New" Outlook

Post by DB Novice »

I have code that will start Outlook and a new message to send email. I am using "New Outlook" now, but the code refers to (and therefore runs) the standard Outlook. Here is an example of what it looks like below. Is it a simple thing to get it to start the "New Outlook" rather than the standard?

Code: Select all

Private Sub Command11_Click()
'Sub SendEmail_Click()
    Dim sql As String
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim adr As String
    Dim objOL As Object
    Dim objMsg As Object
    ' SQL to get unique email addresses
    sql = "SELECT DISTINCT Email FROM qrySafetyTeam"
    Set dbs = CurrentDb
    ' Open recordset
    Set rst = dbs.OpenRecordset(Name:=sql)
    ' Loop through the records
    Do While Not rst.EOF
        'Concatenate email addresses
        adr = adr & ";" & rst.Fields(0)
        rst.MoveNext
    Loop
    ' Close the recordset
    rst.Close
    ' Remove the first ;
    adr = Mid(adr, 2)
    ' Start Outlook
    Set objOL = CreateObject(Class:="Outlook.Application")
    ' Create message
    Set objMsg = objOL.CreateItem(0) ' 0 = olMailItem
    ' Set recipient to yourself
    objMsg.To = "bozo@123456.net"
    ' Set BCC
    objMsg.BCC = adr
    ' Set subject
    objMsg.Subject = "Safety Team"
    ' Set message body
    'objMsg.Body = ""
     objMsg.HTMLBody = "<HTML><BODY><FONT FACE=Merriweather SIZE=14pt><P>This is an email to the Safety Team</P>" & _
        "<P>This is <B>bold</B> and this is <I>italic</I></P></FONT></BODY></HTML>"
    ' Display the message
    objMsg.Display
    'set the font
End Sub

User avatar
HansV
Administrator
Posts: 78518
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: "New" Outlook

Post by HansV »

Unfortunately, the New Outlook does not - and will not - support interfacing with VBA. It's intended to be a platform-independent app, while VBA relies on locally installed code libraries on a desktop computer (Windows/Mac).

So if your users migrate to New Outlook, your code is toast. (Great move from Microsoft... :sad:)
Best wishes,
Hans

DB Novice
Lounger
Posts: 49
Joined: 14 Jan 2015, 23:04

Re: "New" Outlook

Post by DB Novice »

Thanks, Hans! I am still able to go back to the old version and I'm the only one using that code, so I'll be good until Microsoft does something worse.