Okay, so I followed Ron's advice and used his coding. However, I'm
still getting a permission error when someone else uses the
spreadsheet. I have a macro assigned to a button. It opens an email,
fills in the subject and body, adds some attachments, and then waits
for the user to input an email address. It works fine for me. I
created the spreadsheet and it is stored on a shared drive. However,
when another user logs into their computer and tries to use it, it
says that they do not have permission.
I fixed it. Come to find out, it wasn't anything with the coding.
The email that gets generated has attachments. Apparently one of my
attachments had a permissions setting that didn't let certain users
access it...hence the permissions error. We allowed access and the
coding works like a charm.
Thanks for everyone's help and hopefully this will be searched someday
and it will help someone out.
incidentally, here is the coding I used to generate an email, add
stuff to the body, include attachments, and then wait for the user to
enter an email address.
Option Explicit
Sub SendPermitPackage()
'
'Code to send a permit application package via email
'Prompts a new email with a canned subject and body including
attachments
'
Dim wkb As Workbook
Dim wks As Worksheet
Dim Rng As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'****************************************************************************
' For early binding
' Dim olMyApp As Outlook.Application
' Dim olMyEmail As Outlook.MailItem
'
' 'Set the macro to use the Outlook object library [USERS MUST
ACTIVATE
' 'THIS IN THE TOOLS > REFERENCES SECTION!]
' Set olMyApp = New Outlook.Application
' Set olMyEmail = olMyApp.CreateItem(olMailItem)
'****************************************************************************
'****************************************************************************
' For late binding
Dim olMyApp As Object
Dim olMyEmail As Object
Set olMyApp = CreateObject("Outlook.Application")
olMyApp.Session.Logon
Set olMyEmail = olMyApp.CreateItem(0)
'****************************************************************************
'Set the email parameters...i.e. body, subject, attachments...
olMyEmail.Subject = "Permit Application Package"
olMyEmail.Body = "*stuff you want in the body of the email*"
olMyEmail.Attachments.Add ("Z:\COMMON FILES\thing1.pdf")
olMyEmail.Attachments.Add ("Z:\COMMON FILES\thing2.pdf")
olMyEmail.Attachments.Add ("Z:\COMMON FILES\thing3.pdf")
'Display the email before sending it so that the user can input
the email
'address and any other text in the body.
olMyEmail.Display
'release the memory
Set olMyApp = Nothing
Set olMyEmail = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub