crazy mayk with crazy email macro.

Mayk

New Member
Joined
Mar 18, 2002
Messages
18
i was given a mcros which would open outlook and prepare to get ready to send an email.the macro is shown below:

Sub SendEmailNR()
'
' SendEmailNR Macro
'

'
Dim aOutlook As Object, aEmail As Object
On Error Resume Next
Set aOutlook = GetObject(, "Outlook.Application")
On Error GoTo INoOutlook
If aOutlook Is Nothing Then Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(olMailItem)
On Error GoTo 0
aEmail.Subject = "Latest figures"
aEmail.Body = "The figures do not include the last two days of trading."
aEmail.Attachments.Add ThisWorkbook.Path & "\data01.xls"
On Error GoTo INoSend
aEmail.Recipients.Add "bigman@address.com"
aEmail.Send
MsgBox "Email successfully sent"
Exit Sub
INoSend:
MsgBox "Microsoft Outlook is not installed"


End Sub

error message:
COMPILE ERROR.
LABEL NOT DEFINED.
this hapeens when i run it step by step by pressing F8

any idea wot could go wrong?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Yeah, you're error message is telling it to go to a label that doesn't exist. ("INoOutlook" in this case)

Change the line of code that says:

<pre>
INoSend:</pre>

to

<pre>
INoOutlook:</pre>
 
Upvote 0
aEmail.Attachments.Add ThisWorkbook.Path & \As~project~withoutpics.xls

okay next problem accuried in this line.

error msg is
The system cannot find the file specified.

its probably talking about As~project~withoutpics.xls that.isnt?

well i duno wot other specified file i should give.

givin up ...
begging 4 help
 
Upvote 0
On 2002-04-11 14:02, Mayk wrote:
aEmail.Attachments.Add ThisWorkbook.Path & As~project~withoutpics.xls

okay next problem accuried in this line.

error msg is
The system cannot find the file specified.

its probably talking about As~project~withoutpics.xls that.isnt?

well i duno wot other specified file i should give.

givin up ...
begging 4 help

I don't see that line of code in your original sample, I see this line though:

<pre>
aEmail.Attachments.Add ThisWorkbook.Path & "data01.xls" </pre>

I'm assuming that you changed the code yourself to the name of the workbook you're trying to send. Basically the error is saying that the workbook "As~project~withoutpics.xls" doesn't exist, at least not in the same directory as the file you've got this VBA in.

My suggestion is to check the filepath of the workbook the code is in and the location of the "As~project~withoutpics.xls" file.

HTH
 
Upvote 0
Yeah, I noticed that but it didn't register. Good catch.



_________________<font color = green> Mark O'Brien
This message was edited by Mark O'Brien on 2002-04-11 14:26
 
Upvote 0
Try This my friend

Sub EMAIL()


Mailee = InputBox("Please Enter Name to Send sheet to.........")
subj = InputBox("Please enter eMail Subject..............")
Application.Dialogs(xlDialogSendMail).Show arg1:="", arg2:="As Requested"
Recipients = Mailee.Subject = subj.Close
End Sub

hope it works::::did not check it first
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,198
Members
448,554
Latest member
Gleisner2

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