+ Reply to Thread
Results 1 to 6 of 6

Macro Bugs (send email)

  1. #1
    Registered User
    Join Date
    05-27-2022
    Location
    South Carolina
    MS-Off Ver
    64bit
    Posts
    4

    Macro Bugs (send email)

    I am using the below code that I found on the web. I am having issues getting the email to send automatically. All actions will work except the .Send function.
    Any help would be appreciated. Thanks in advance.
    Note: I have note experience with macros.


    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    Dim Outlook As Object, EMail As Object

    Set Outlook = CreateObject("Outlook.Application")

    Set EMail = Outlook.CreateItem(0)

    With EMail
    .To = "sample.com"
    .CC = ""
    .BCC = ""
    .Subject = "PLC Change Log Update"
    .Body = "Sender has modified the attached file"
    .Attachments.Add ActiveWorkbook.FullName
    .Send
    '.Display



    End With


    Set EMail = Nothing

    Set Outlook = Nothing
    Application.Quit
    ThisWorkbook.save


    End Sub

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,361

    Re: Macro Bugs (send email)

    Can be issues with out of date antivirus as well as others, there is usually a pop up asking if you want to allow the interaction between Excel and Outlook - it could be in the background.

    Can also be caused if the email address has not been accepted - have you tried it with a real email address? Or at least '[email protected]' - it may need the @ symbol to be present.

    Might be worth having a read of the below:
    https://docs.microsoft.com/en-us/out...on-your-behalf
    Last edited by CheeseSandwich; 05-27-2022 at 08:54 AM.
    If things don't change they stay the same

  3. #3
    Registered User
    Join Date
    05-27-2022
    Location
    South Carolina
    MS-Off Ver
    64bit
    Posts
    4

    Re: Macro Bugs (send email)

    I don't think there is an issue with antivirus. Also, if I comment out .Send and put in .Display, outlook will open with my email. I only placed sample.com in this thread to have my work email out.
    Attached is the only pop-up I get after running the script.
    Attachment 781966

  4. #4
    Registered User
    Join Date
    05-27-2022
    Location
    South Carolina
    MS-Off Ver
    64bit
    Posts
    4

    Re: Macro Bugs (send email)

    Attachment 781967
    ...........

  5. #5
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,361

    Re: Macro Bugs (send email)

    Also, if I comment out .Send and put in .Display
    This is exactly what will happen if the email address is not valid - it is happy to display an email address that is not valid but it can't send to it.

    It is also what happens if the security issue has reared its ugly head - hence the provided link.

    Have you tried it with a valid email address?

  6. #6
    Registered User
    Join Date
    05-27-2022
    Location
    South Carolina
    MS-Off Ver
    64bit
    Posts
    4

    Re: Macro Bugs (send email)

    Yes, I've tried a few different emails. I have also tried adding my display name as shown in outlook. Display will populate an email address in an outlook pop-out. Select send in the pop-out and I receive an email.
    Also, I cannot change the antivirus settings. My IT department has that looked out.

+ 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. A VBA macro to send an email with any email client installed ?
    By nbelal in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-06-2021, 02:59 PM
  2. [SOLVED] Email Send Macro - 0 pulling into CC field when no email address present
    By toriwoo86 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-26-2021, 02:18 PM
  3. .display half working, .send bugs on email being sent on behalf of
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2018, 09:34 AM
  4. Replies: 4
    Last Post: 01-30-2016, 02:13 PM
  5. Macro to send email with attachment for each unique email Ids
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-06-2014, 07:12 AM
  6. Excel Email Macro VBA - How to send an email once all required fields have been fille
    By wallacm2009 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2012, 10:51 AM
  7. Replies: 6
    Last Post: 12-02-2011, 02:14 PM

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