Skip to content

Free Excel Training 2022

Excel Training Tutorials 2022

  • Home
    • About
    • Contact
    • Privacy Policy
  • Excel Essentials
  • Excel Functions
    • Excel 2003
    • Excel 2007
    • Excel 2010
  • Excel in Hindi
  • Excel VBA
    • Excel 2003 VBA
    • Excel 2007 2010 2013 VBA
  • YouTube
    • YouTube Advanced VBA
    • YouTube Hindi
  • Books
  • What’s New

Month: January 2020

Send Emails From Specific Account in Outlook

Posted on January 28, 2020January 28, 2020 by Dinesh Kumar Takyar

How to send emails from a specific account in Outlook automatically using VBA.
Below is the complete VBA code:
Option Explicit

Sub EmailAccounts()

‘add a reference to the Microsoft Outlook Library in your Excel workbook

Dim OutApp As Outlook.Application

Dim i As Long

Dim erow As Long

erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

Set OutApp = CreateObject(“Outlook.Application”)

For i = 1 To OutApp.Session.Accounts.Count

Sheet1.Cells(erow, 1) = OutApp.Session.Accounts.Item(i)

Sheet1.Cells(erow, 2) = i

erow = erow + 1

Next i

End Sub

Sub MailFromAnyAccount()

‘Works in Excel 2007 or higher

‘add a reference to the Microsoft Outlook Library in your Excel workbook

Dim OutApp As Outlook.Application

Dim OutMail As Outlook.MailItem

Dim OutAccount As Outlook.Account

Dim strbody As String

Set OutApp = CreateObject(“Outlook.Application”)

Set OutMail = OutApp.CreateItem(olMailItem)

‘Use the account based on the number

Set OutAccount = OutApp.Session.Accounts.Item(1)

‘Or use the email address

‘Set OutAccount = OutApp.Session.Accounts(“[email protected]”)

strbody = “You can learn the following at exceltrainingvideos.com:” & vbNewLine & vbNewLine & _

“Visual Basic for Applications VBA” & vbNewLine & _

“Pivot Tables” & vbNewLine & _

“Solver” & vbNewLine & _

“Data Analysis & charts” & vbNewLine & _

“More…” & vbNewLine & vbNewLine & _

“Dinesh K Takyar”

On Error Resume Next

With OutMail

.To = “[email protected]”

.CC = “[email protected];[email protected]”

.BCC = “[email protected]”

.Subject = “What do you want to learn today in MS Excel?”

.Body = strbody

.SendUsingAccount = OutAccount

.Display ‘or use .Send

End With

On Error GoTo 0

Set OutMail = Nothing

Set OutApp = Nothing

Set OutAccount = Nothing

End Sub

Posted in Excel VBA 2013Tagged How to Send Emails from a Specific Account in Outlook automatically, Send Emails from a Specific Account in Outlook 29 Comments

Posts navigation

Older posts
Newer posts

Change Language

en English
af Afrikaanssq Albanianam Amharicar Arabichy Armenianaz Azerbaijanieu Basquebe Belarusianbn Bengalibs Bosnianbg Bulgarianca Catalanceb Cebuanony Chichewazh-CN Chinese (Simplified)zh-TW Chinese (Traditional)co Corsicanhr Croatiancs Czechda Danishnl Dutchen Englisheo Esperantoet Estoniantl Filipinofi Finnishfr Frenchfy Frisiangl Galicianka Georgiande Germanel Greekgu Gujaratiht Haitian Creoleha Hausahaw Hawaiianiw Hebrewhi Hindihmn Hmonghu Hungarianis Icelandicig Igboid Indonesianga Irishit Italianja Japanesejw Javanesekn Kannadakk Kazakhkm Khmerko Koreanku Kurdish (Kurmanji)ky Kyrgyzlo Laola Latinlv Latvianlt Lithuanianlb Luxembourgishmk Macedonianmg Malagasyms Malayml Malayalammt Maltesemi Maorimr Marathimn Mongolianmy Myanmar (Burmese)ne Nepalino Norwegianps Pashtofa Persianpl Polishpt Portuguesepa Punjabiro Romanianru Russiansm Samoangd Scottish Gaelicsr Serbianst Sesothosn Shonasd Sindhisi Sinhalask Slovaksl Slovenianso Somalies Spanishsu Sudanesesw Swahilisv Swedishtg Tajikta Tamilte Teluguth Thaitr Turkishuk Ukrainianur Urduuz Uzbekvi Vietnamesecy Welshxh Xhosayi Yiddishyo Yorubazu Zulu

Please click the icon to access all YouTube videos, if you can't see the video on the main page:

View All Posts

View All Pages

Share with Friends:
              

Create a website that's free with GoDaddy!
Proudly powered by WordPress | Theme: sosimple by Fernando Villamor Jr..

Copyright ©2023 exceltrainingvideos.com