Results 1 to 7 of 7

Thread: Automated Daily Email in Microsoft Outlook

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    3

    Question Automated Daily Email in Microsoft Outlook

    Hi, let me first introduce myself as a new member and a complete VBA noob. I found the site looking for a way to write a macro in Microsoft Outlook. I have used macros in Excel but I barely write the code, I cheat and use the "record" button.

    What I need to do is this:
    I need a way that I can have outlook send an email with a short bit of text every day. It will be the same text (just 3 words really). It will be sent to the same person every day. It would be really great if I could make it randomly send the email between 6am and 7am. If this is too much work then one standard time would be fine, or it could be when I start outlook each morning. If anyone can help I'd really appreciate it.

  2. #2
    Hyperactive Member Davadvice's Avatar
    Join Date
    Apr 2007
    Location
    Glasgow (Scotland)
    Posts
    440

    Re: Automated Daily Email in Microsoft Outlook

    hi,

    Sending mail via Outlook (Not Outlook Express) requires autorisation from the user. there is a security feature that prevents "mail Boming" using MS outlook.

    there is a way to send the mail but it will require some imput from a user when the mail is to be sent.

    if you want to send the mail by cliking the button then let me know and i will get some code up for you.

    also please confirm it is outlook and the Version?

    thanks

    David
    This is Blank

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    3

    Thumbs up Re: Automated Daily Email in Microsoft Outlook

    Quote Originally Posted by Davadvice
    hi,

    Sending mail via Outlook (Not Outlook Express) requires autorisation from the user. there is a security feature that prevents "mail Boming" using MS outlook.

    there is a way to send the mail but it will require some imput from a user when the mail is to be sent.

    if you want to send the mail by cliking the button then let me know and i will get some code up for you.

    also please confirm it is outlook and the Version?

    thanks

    David
    Yes sir, outlook 2003 it is.

  4. #4
    Hyperactive Member Davadvice's Avatar
    Join Date
    Apr 2007
    Location
    Glasgow (Scotland)
    Posts
    440

    Re: Automated Daily Email in Microsoft Outlook

    Hi,

    here is the code you will need to send the mail.

    i'm not too sure about using a timer with outlook to send at a specific time. I will look into it later and get back.

    If you go to tools>Macro and click on Vb Editor

    on the left expand the tree and select this outlook session.

    paste the below code and add an e-mail address (your own should be used to test) to this line in the code. omsg.Recipients.Add "enterEmailAddressHERE"

    vb Code:
    1. Public Sub SndFirstMail()
    2. Dim strmsg As String
    3. Dim oApp As New Outlook.Application
    4. Dim omsg As Outlook.MailItem
    5.  
    6. strmsg = "Test" & vbCrLf & " I  am testing this message"
    7.  
    8. Set omsg = oApp.CreateItem(olMailItem)
    9. omsg.Recipients.Add "enterEmailAddressHERE"
    10. omsg.Body = strmsg
    11. omsg.Send
    12. End Sub


    if you press F8 it will allow you to step through the code.

    good luck

    David
    This is Blank

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    3

    Re: Automated Daily Email in Microsoft Outlook

    How will it know to send this once per day?

  6. #6
    Hyperactive Member Davadvice's Avatar
    Join Date
    Apr 2007
    Location
    Glasgow (Scotland)
    Posts
    440

    Re: Automated Daily Email in Microsoft Outlook

    Hi
    you will have to add a sub and set up a timer when the timer reaches a Value you can check the system time then if the time is within the range you require you send the mail.

    If outlook is open all the time(24/7) then you should set a boolean Value to mark that you have sent the mail for that date.

    I would assume there may be an onload type function when you open outlook that may also be able to call the SndFirstMail procedure.

    I am no expert in coding outlook so i am unsure of how to do this.

    I would advise that you should set up a small exeutable (if available) that could perform this task. if you don't have this available you could use access, or Excell and leave these open so it can send the mail.

    thanks
    David
    This is Blank

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Automated Daily Email in Microsoft Outlook

    If you write code in the VBA editor then it will be easier to automate. If you need this to be distributed to other users then perhaps its best to write a ful AddIn for it.

    You may want to check out my Office FAQ (link in signature) for more information.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width