How do I create a custom pick list in VB for an outlook automated email?

Status
Not open for further replies.

Gary Lewis

New Member
Outlook version
Outlook 2016 64 bit
Email Account
POP3
I have a case where the "distribution" will not change very much, and would have multiple choices. The code below is what I have so far, it appears to be working for the most part, but the only value that populates to my .TO is the values in strP0list no matter what I pick from the combobox
Sub OutageNotification()
'-----------------------------------------
'DECLARE AND SET VARIABLES
Dim myOutlok As Object
Dim myMailItm As Object
Dim Signature As String
Dim strUsrPmt1 As String
Dim strDistroList As String
Set otlApp = CreateObject("Outlook.Application")
Set OtlNewMail = otlApp.CreateItem(olMailItem)
Dim message, title, defaultValue As String
message = "Enter your issue"
title = "Subject InputBox"
defaultValue = "No Issue"
strUsrPmt1 = InputBox(message, title, defaultValue, 25, 45)

strP0list = "List1-1@somewhere.com;List1-2@somewhere.com"
strP1list = "List2-1@somewhere.com;List2-2@somewhere.com"
strP2list = "List3-1@somewhere.com;List3-2@somewhere.com"
strP3list = "List4-1@somewhere.com;List4-2@somewhere.com"
'-----------------------------------------
'Get Distribution List
UserForm1.Show
Select Case lstNum
Case -1
' -1 is what you want to use if nothing is selected
strDistroList = "Please enter a valid email"
Case 0
strDistroList = strP0list
Case 1
strDistroList = strP1list
Case 2
strDistroList = strP2list
Case 3
strDistroList = strP3list
End Select
'-----------------------------------------
'GET DEFAULT EMAIL SIGNATURE
'Signature = Environ("appdata") & "\Microsoft\Signatures\"
' If Dir(Signature, vbDirectory) <> vbNullString Then
' Signature = Signature & Dir$(Signature & "*.htm")
' Else:
' Signature = ""
' End If
' Signature = CreateObject("Scripting.FileSystemObject").GetFile (Signature).OpenAsTextStream(1, -2).ReadAll
'-----------------------------------------
'CREATE EMAIL
OtlNewMail.HTMLBody = Signature
With OtlNewMail
.To = strDistroList
.CC = "someone@somewhere.com"
.Subject = "Notification: " & strUsrPmt1
.HTMLBody = "<p><font face=""Calibri"" size=""3"">" & "<B>" & "Team-" & "<BR>" & "<BR>" & "</B>" & "<I>" & "This is an important notice about ……(Describe the impacted technology)" _
& "<BR>" & "<BR>" & "</I>" & "<B>" & "What's happening?" & "</B>" & "<BR>" & "<BR>" & "<I>" & _
"In order to continue to reduce our …… (Describe the issue or effort)" & "</I>" & "<BR>" & "<BR>" & "<B>" & "What's the impact?" & "</B>" & "<BR>" & "<BR>" _
& "<I>" & "Beginning at 8 PM EST on Friday, December 9, network and phone connectivity will be .... (Describe the impact)" & _
"</I>" & "<BR>" & "<BR>" & "<B>" & "What's not impacted?" & "</B>" & "<BR>" & "<BR>" & "<I>" & "This does not impact remote.... (Describe what is not impacted)" _
& "</I>" & "<BR>" & "<BR>" & "<B>" & "Questions?" & "</B>" & "<BR>" & "<BR>" & "<I>" & "Contact me directly for questions or concerns." & "</I>" & "<BR>" & "<BR>" & Signature
.Display
'.Send
End With

'-----------------------------------------
'CLEANUP
Set OtlNewMail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing
'-----------------------------------------
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Distribution1"
.AddItem "Distribution2"
.AddItem "Distribution3"
.AddItem "Distribution4"
End With
End Sub
Private Sub btnOK_Click()
lstNum = ComboBox1.ListIndex
Unload Me
End Sub
Can anybody offer some assistance with this? I am an old guy trying new things, and pretty much looking for any assistance, would someone be so kind as to review and show me the error of my ways?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J PSA: How to create custom keyboard shortcut for "Paste Unformatted Text" in Outlook on Windows Outlook VBA and Custom Forms 1
C Create Meeting With Custom Form Outlook VBA and Custom Forms 2
S Create a clickable custom column field Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
L Create Custom Form Using Outlook 0
Diane Poremsky Create a custom field for Outlook messages Using Outlook 0
Diane Poremsky Create a Custom Numbering Field for Outlook messages Using Outlook 0
I Create custom Outlook 2013 Rule in Office 365 Outlook VBA and Custom Forms 5
T Create custom calendar entry form... Outlook VBA and Custom Forms 3
S Create a custom "Send" Button Outlook VBA and Custom Forms 3
E Create a URL hyperlink in an Outlook custom form? Outlook VBA and Custom Forms 2
R Can I create custom subgroups on the ribbon? Using Outlook 5
D Create additional custom flag descriptions (other than Send E-Mail, Call etc.) Using Outlook 1
J How to create a user defined dropdown list field for a custom contact form Using Outlook 3
O Outlook 2010 - How to create custom Group By Arrangements for email Using Outlook 3
P Create appointment to custom (shared) outlook calendar Outlook VBA and Custom Forms 3
C How to create a custom 'View Type' Outlook VBA and Custom Forms 7
Q How do I create a custom action for a rule? (Save as "Nfy.MSG") Outlook VBA and Custom Forms 1
S Create Outlook Task from Template and append Body with Email Body Outlook VBA and Custom Forms 4
B Modify VBA to create a RULE to block multiple messages Outlook VBA and Custom Forms 0
J Want to create a button on the nav bar (module add-in) to run code Outlook VBA and Custom Forms 2
B How to create a button that sorts and selects the most recent message with ONE click Using Outlook 2
W Create a Quick Step or VBA to SAVE AS PDF in G:|Data|Client File Outlook VBA and Custom Forms 1
Wotme create email only data file Using Outlook 1
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
J How to create a drop down user defined field that will appear on an inbox view Outlook VBA and Custom Forms 8
Commodore Any way to create "from-only" account on Outlook 2021? Using Outlook 1
L Capture email addresses and create a comma separated list Outlook VBA and Custom Forms 5
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
NVDon Create new Move To Folder list Outlook VBA and Custom Forms 0
D Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
G Create ordinal numbers for birthday Outlook VBA and Custom Forms 2
O Outlook 365 - How to create / copy a new contact from an existing one? Using Outlook 5
D Create new email from the received Email Body with attachment Outlook VBA and Custom Forms 10
A How to create fixed signatures for aliases that process through GMAIL? Outlook VBA and Custom Forms 0
P Can I create a Rule that sends me an email when I get a Task? Using Outlook 2
M How create a Rule to filter sender's email with more that one @ sign Using Outlook 1
B Can I create a local PST file for SPAM on a drive that is usually disconnected? Using Outlook 3
Chiba Create an appointment for all the members Outlook VBA and Custom Forms 1
L automaticaly create a teams meeting with a sync Using Outlook 0
D Can Exchange Admin Center create a pst for users email/contacts/calendar? Exchange Server Administration 0
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
F How to create phone number as links in notes of Contacts Using Outlook 2
Nessa Can't create new appointment Using Outlook 1
A Create date folder and move messages daily Outlook VBA and Custom Forms 1
C Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
O Multiple email accounts - hesitate to create a new profile Using Outlook 3
G Can't create Folder Groups in Outlook 2013 Using Outlook 0
N Outlook rules don't create a copy for bcc'ed emails Using Outlook 3

Similar threads

Back
Top