Hello, Everyone - I have a major headache to achieve in the next week. I have two blocks of VBA code, but I'm not sure which one is better for my needs (not to mention what the difference between them is)...
First...
I want to create an automated process on an Access form that does the following things for a Human Resources department:
- (Fields on form are filled out, and the user has come to the "Add Record/Automate" button...
- <Button is clicked>
- An Outlook template e-mail to an employee is opened and certain parts of it are populated by certain fields from the form/table.
- A second Outlook template e-mail to the employee's manager is opened and certain parts of it are populated by certain fields from the form/table.
- Both Outlook e-mails are sent.
I have the following blocks of code for one e-mail automation, but I'm not sure how they're different and which one I can adapt to automate two mailings with one button click:
Dim objFolder As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace
Dim objItems As Outlook.Items
Dim objNewMail As Outlook.MailItem
Dim objUPS As Outlook.UserProperties
Dim objUP As Outlook.UserProperty
Set objNS = Outlook.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderInbox)
Set objItems = objFolder.Items
Set objNewMail = objFolder.Items.Add("IPM.Note.MyCustomMailForm")
objNewMail.Subject = "Send Me"
objNewMail.To = "(E-Mail Removed)"
Set objUPS = objNewMail.UserProperties
Set objUP = objUPS.Item("CustomField1")
objUP.Value = "My Value"
objNewMail.Send
AND......
Dim olApp As Outlook.Application
Dim olNs As Outlook.NameSpace
Dim MailBoxFolder As Outlook.MAPIFolder
Dim itm As Outlook.MailItem
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set MailBoxFolder = olNs.GetDefaultFolder(olFolderInbox)
Set itm = MailBoxFolder.Items.Add("IPM.Note.MyTemplate")
itm.UserProperties.Item("FieldNameHere").Value = "Joe Smith"
----
What is the difference between the ol and obj prefixes? I can recognize similar lines in the two, but don't understand the differences in prefix or where my particular folder/items names should go. Any help would be appreciated! Thanks ahead of time!
Soule