+ Reply to Thread
Results 1 to 6 of 6

Create a macro in outlook to check the To List in a new Mail

  1. #1
    Registered User
    Join Date
    04-04-2017
    Location
    Hyderabad
    MS-Off Ver
    Outlook 2016
    Posts
    3

    Create a macro in outlook to check the To List in a new Mail

    Hi,

    I am new to macros and VB.
    I have to create a macro in outlook. While sending a new mail this macro should check, whether all the recipients have gmail.com suffix.

    I enabled the developer tool in Outlook and trying to write some procedure in Visual Basic to perform this action.
    But the procedure is not getting visible in Macro section of Outlook.

    Can anyone please suggest, the correct way of writing a macro for this.

    Thanks
    Rahul

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Create a macro in outlook to check the To List in a new Mail

    Hi

    this macro should check whether any recipients in the active mail item have email addresses that do not end in gmail.com

    Please Login or Register  to view this content.
    Last edited by NickyC; 04-04-2017 at 09:21 PM. Reason: remove redundant code

  3. #3
    Registered User
    Join Date
    04-04-2017
    Location
    Hyderabad
    MS-Off Ver
    Outlook 2016
    Posts
    3

    Re: Create a macro in outlook to check the To List in a new Mail

    Hi Nicky,
    Thanks for replying.
    I am getting below error, while using above code.

    "Run-time error'424':
    Object required"

    The error is occuring in below line of code:
    Set ThisItem = GetCurrentItem

    Am i missing anything to include here.

    Thanks
    Rahul

  4. #4
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Create a macro in outlook to check the To List in a new Mail

    My apologies, I included a reference to a separate macro

    try this

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-04-2017
    Location
    Hyderabad
    MS-Off Ver
    Outlook 2016
    Posts
    3

    Re: Create a macro in outlook to check the To List in a new Mail

    Thanks Nicky, This code is able to fetch the "To list".
    Now the problem is when we do a Ctrl+K, the mail id becomes a username.
    Is there any way, we can fetch mail id, corresponding to the username and then check on it for gmail.com suffix.

    Thanks
    Rahul

  6. #6
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Create a macro in outlook to check the To List in a new Mail

    Hi Rahul
    this is probably a better version as it does not rely on splitting a text string to get email addresses.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create Outlook mail with dynamic .Body and static .HTMLBody
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2014, 04:45 AM
  2. [SOLVED] automatically fill template and create Outlook mail
    By Bax in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-18-2013, 05:46 AM
  3. Macro to create an e-mail using an Outlook Template and add an attachment
    By hsarro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2012, 12:25 PM
  4. VBA Code to check, if, mail was sent through Outlook (2007) at the time specified
    By zubinosh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-04-2012, 11:51 AM
  5. How to create a mail in outlook using vba
    By onkar in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 07-06-2011, 05:03 AM
  6. outlook redemtion macro cant send mail if outlook is not open ?
    By okl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-03-2010, 07:35 AM
  7. Using Excel to create e-mail for Outlook Express
    By djvice in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-23-2008, 12:54 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1