Send E-mail Macro

davulf

Active Member
Joined
Jul 4, 2005
Messages
273
Hi There, I am trying to get a label (Need Help?) when clicked to open up the box for composing a message.

Code:
Private Function sendEmail()

Dim strEmail As String

strEmail = "email@no.com"
DoCmd.SendObject , , , strEmail, , , , , True

End Function

This code works fine, and brings up the message box, but if I click on the 'x' to close it, an error is produced. I believe this is because the function didn't complete, as the e-mail was never sent.

How can I prevent this from happening, if, say, the user decides after clicking that he doesn't want to send the e-mail, or has clicked on it in error.

Thanks,
DaVuLF
 

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.

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
Put in the following two "On Error" statements.
Code:
Private Function sendEmail() 

Dim strEmail As String 

    strEmail = "datadictionary@purolator.com" 
    On Error Resume Next
        DoCmd.SendObject , , , strEmail, , , , , True 
    On Error GoTo 0
End Function
 
Upvote 0

davulf

Active Member
Joined
Jul 4, 2005
Messages
273
Thanks Vic, that helped a lot. Know any way to make the cursor change to a hand when it passes over the label? Currently you have to know it is a link beforehand.
 
Upvote 0

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
On MouseMove

Use the OnMouseMove event to change the cursor. I would put a box behind the label, but is bigger than the label, that also uses OnMouseMove to change the cursor back if it does not change back on it's own. If you used a regular Text Box and marked that it was a hyperlink, I think Access would take care of the cursor change for you.
 
Upvote 0

Forum statistics

Threads
1,191,286
Messages
5,985,749
Members
439,979
Latest member
alekun86

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
Top