Access and Outlook???

lorenambrose

Active Member
Joined
Sep 17, 2008
Messages
265
I have the following VBA in a form:

Private Sub Command23_Click()

If Me.Email = "Sent" Then
If MsgBox("Notification has already been sent. Do you wish to re-send?", vbYesNo, "Send Notification?") = vbYes Then
DoCmd.RunMacro "SendMail"
Else
DoCmd.Close
End If

Else
DoCmd.RunMacro "SendMail"

End If

End Sub


My issue is that when it executes a window pops up prompting the user to "Allow", "Deny" or "Help". SEE ATTACHMENT.


<TABLE style="WIDTH: auto; DISPLAY: inline" id=ipb-attach-table-45639-0-14210200-1302222424 cellSpacing=0 cellPadding=0><TBODY><TR><TD>
img-resized.png
Reduced 85%
654 x 503 (55.18K)​




</TD></TR></TBODY></TABLE>​
******** type=text/javascript>//*********>
http://i630.photobucket.com/albums/uu24/lorenambrose/Email2.jpg


I can not see any way to prevent the user from selecting "Deny" or "Help", and when they do errors happen causing the macro to stop and the debugger to activate.


<TABLE style="WIDTH: auto; DISPLAY: inline" id=ipb-attach-table-45640-0-14259900-1302222424 cellSpacing=0 cellPadding=0><TBODY><TR><TD>
img-resized.png
Reduced 79%
472 x 263 (22.01K)​




</TD></TR></TBODY></TABLE>​
******** type=text/javascript>//*********>





Is there a way around this? Please Help.

Maybe VBA instead of the email macro.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi there

You have encountered a problem that many of us have faced at one time or another. One possible workaround (which I did use myself a few years back) is Outlook Redemption. See the link here: http://www.dimastr.com/redemption/ If you want to use it in a commercial application then you will need to purchase a licence (USD$199 currently). If you do need the email functionality then your best bet may be to download the free developer version, see if it meets your needs and then purchase the licence if you go ahead with it.

HTH
DK
 
Upvote 0
Sub SendMessage(Optional AttachmentPath)
Dim olookApp As Outlook.Application
Dim olookMsg As Outlook.MailItem
Dim olookRecipient As Outlook.Recipient
Dim olookAttach As Outlook.Attachment
' create the Outlook session.
Set olookApp = CreateObject("Outlook.Application")
' create the message.
Set olookMsg = olookApp.CreateItem(olMailItem)
With olookMsg
' add the To recipient(s) to the message.
Set olookRecipient = .Recipients.Add("Email.Address")
olookRecipient.Type = olTo
'Copy & Paste the above 2 lines for additional "To" recipients

' add the CC recipient(s) to the message.
'Set olookRecipient = .Recipients.Add("Email.Address")
'olookRecipient.Type = olCC
' set the Subject, Body, and Importance of the message.
.Subject = "My E-mail Message Subject Line Info"
.Body = "Message Text" & vbCrLf & vbCrLf
.Importance = olImportanceNormal
'.Importance = olImportanceHigh 'High importance
' add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set olookAttach = .Attachments.Add(AttachmentPath)
End If
' resolve each Recipient's name
For Each olookRecipient In .Recipients
olookRecipient.Resolve
If Not olookRecipient.Resolve Then
olookMsg.Display ' display any names that can't be resolved
End If
Next
.Send
End With
Set olookMsg = Nothing
Set olookApp = Nothing

End Sub

The above code can be called from your macro. Where you have the SendObject line in your macro, substitute it with a RunCode line and point it at the function above using a function name of your choosing and filling in appropriate information. If you use the builder to put the reference to the function in your macro, you'll see something like this: FunctionName(< < AttachmentPath > <ATTACHMENTPATH>>). If there is no attachment, remove the text between the parens, otherwise, within quotes, insert the path and file name of the attachment: FunctionName("MyFile'sPath\MyFile.Extension"). In your vba module, if you don't already have it, you'll need a VBA Reference to Outlook.

When this code executes, assuming there are no errors, the message is sent instantly. No dialog box will pop up with choices.

I hope you find this helpful.

Phil...
 
Last edited:
Upvote 0
.....

When this code executes, assuming there are no errors, the message is sent instantly. No dialog box will pop up with choices.

I hope you find this helpful.

Phil...

Hi there

Are you sure? When I run your code i get the normal security warning "A program is trying to access e-mail addresses you have stored in Outlook...". I'm using Outlook 2003 version 11.8325.8329 SP3.

Regards
DK
 
Upvote 0
I'm using the 2007 version and I don't get that warning. Have you set up your security certificate? (Self Sign)

Phil...
 
Upvote 0
I'm using the 2007 version and I don't get that warning. Have you set up your security certificate? (Self Sign)

Phil...

You didn't mention that the certificate was required. I've not used self-sign myself but my understanding is that they are only useful when used on the computer containing the certificate. If someone else opens the Access file they they'll still get the security warnings.

DK
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,519
Members
452,921
Latest member
BBQKING

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