.Send function is not working for by below code

siddo

Board Regular
Joined
May 26, 2020
Messages
106
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
VBA Code:
Sub Mail_workbook_Outlook_1()

Dim UserInputToEmail As String

    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    
 UserInputToEmail = Application.InputBox("Enter your email id")

    On Error Resume Next
    With OutMail
        .to = UserInputToEmail
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = "Hi there"
        .Attachments.Add ActiveWorkbook.FullName
        .Send
 Application.Wait (Now + TimeValue("0:00:15"))
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
when you step through with F8 is userinput email fully formed. Is outlook running. Do you have authority to send through the account
 
Upvote 0
when you step through with F8 is userinput email fully formed. Is outlook running. Do you have authority to send through the account
Yes so when I use .Display it works fine, Outlook pops open with an attachment
 
Upvote 0
T
Yes so when I use .Display it works fine, Outlook pops open with an attachment
Tried removing on error next from the above code and got this as error "Run time error 287 Application defined or object defined error" can you help?
 
Upvote 0
Or if somone can help me with the fresh written code without any errors, appreciated
 
Upvote 0
FWIW the code works fine for me, even with the On Errors commented out.?
 
Upvote 0
FWIW the code works fine for me, even with the On Errors commented out.?
I dont know why im facing this issue then. Can you tell me what references you have added in the tools section of vba?
 
Upvote 0
i got my code from the Ron De Bruin site. Outlook balks at sending mails that it can't have scanned
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top