Using Data From Combo Box in Appointment Body

George Z

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
I am attempting to take a different spin on the tutorial below:

Select from a List of Subjects before Sending a Message
Select from a List of Subjects before Sending a Message


I am attempting to utilize this form and macro for adding data to the body of an appointment item. Currently my macro utilizes input boxes to include several different data entries into the appt.body

I would love to add data to the appt.body using both input boxes and combo boxes. However if I add the form, code, and macro code. The input box data overrides the combobox data.If I rem the appt.body inputbox data the combobx adds the data to the body. It seems either one or the other will populate the body not both.

Any way of utilizing bot input boxes and combo boxes to the appt.body? Or any way for the userform to include both text box and combo box data to the appt.body?



Code:
Sub CreateMeetingatContactLocation()
    
Dim oOL As Outlook.Application
Dim NS As Outlook.NameSpace
Dim objOwner As Outlook.Recipient
Dim objAppt As Outlook.AppointmentItem
Dim objAppointment As Outlook.AppointmentItem
Dim objContact As Outlook.ContactItem
Dim strPhone As String
     
Set NS = Application.GetNamespace("MAPI")
  Set objOwner = NS.CreateRecipient("customerdb@beatonindustrial.com")
    objOwner.Resolve
      
If objOwner.Resolved Then
    'MsgBox objOwner.Name
Set newCalFolder = NS.GetSharedDefaultFolder(objOwner, olFolderCalendar)
End If
Set oOL = Outlook.Application
Set objAppt = newCalFolder.Items.Add("IPM.Appointment.Beaton Service Form 4.3")
Set objContact = oOL.ActiveExplorer.Selection.Item(1)

' oMail.Display
  
   UserForm1.Show

  '  MsgBox "user chose " & lstNo & " from combo"

    Select Case lstNo
    Case -1
         objAppt.Body = objAppt.Body
    Case 0
         objAppt.Body = "Subject 1"
    Case 1
         objAppt.Body = "Subject 2"
    Case 2
         objAppt.Body = "Subject 3"
    Case 3
         objAppt.Body = "Subject 4"
    Case 4
         objAppy.Body = "Subject 5"
    End Select

inputdata = InputBox("Please Enter Service Technican and Van Number in the FollowinG Format 14 MM/TS")
inputdata1 = InputBox("Please Enter a Descpiption of the Problem")
inputdata2 = InputBox("If a Man Lift is Required to Complete Service please note if lift will be provided by Beaton or Customer. If no Manlift is Needed enter Not Required")
inputdata3 = InputBox("Please Enter Company Hours of Operation to Complete Service")
inputdata4 = InputBox("Please Enter Location and Status of Required Parts if Applicable. Enter N/A if Not Applicable.")
inputdata5 = InputBox("Please Enter the Priority Level of Equipment Failure and Date Customer is Expecting Service")
inputdata6 = InputBox("Please Enter any Other Additional Notes Relevant to Service Request, Customer Expectation, and or Technical Details")
inputdata7 = InputBox("Add Dropbox Link for any Related File Attachments")

' Use Company for Location
If objContact.CompanyName <> "" Then
    objAppt.Subject = inputdata & " , " & inputdata5 & ", " & objContact.CompanyName & ", - OR - " & objContact.FullName & " , Phone: " & objContact.BusinessTelephoneNumber & " , Cell: " & objContact.MobileTelephoneNumber
' Use Business address if available, else home address
If objContact.BusinessAddress <> "" Then
    objAppt.Location = objContact.BusinessAddressStreet & "," & objContact.BusinessAddressCity & "," & objContact.BusinessAddressState & "," & objContact.BusinessAddressPostalCode
    strPhone = objContact.BusinessTelephoneNumber
Else
  objAppt.Location = objContact.HomeAddressStreet & ", " & objContact.HomeAddressCity & " " & objContact.HomeAddressState & " " & objContact.HomeAddressPostalCode
    strPhone = objContact.HomeTelephoneNumber
End If
 
' Add contact's name and phone number to the body
    objAppt.Body = "DESCRIPTION OF PROBLEM: " & inputdata1 & vbNewLine & vbNewLine & "MANLIFT: " & inputdata2 & vbNewLine & vbNewLine & "HOURS OF OPERATION: " & inputdata3 & vbNewLine & vbNewLine & "REQUIRED PARTS AND STATUS: " & inputdata4 & vbNewLine & vbNewLine & "ADDITIONAL NOTES: " & inputdata6 & vbNewLine & vbNewLine & "FILE ATTACHMENTS: " & inputdata7
    objAppt.Display
    

   
Set objAppointment = Nothing
If objAppointment Is Nothing Then
                With objAppt
                .AllDayEvent = True
                .BusyStatus = olBusy
  End With
End If

Set objContact = Nothing
Set oOL = Nothing

End If

End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Any way of utilizing bot input boxes and combo boxes to the appt.body? Or any way for the userform to include both text box and combo box data to the appt.body?
It should work.... you need to use something like this:
for the cases:
Case -1
strBody = objAppt.Body
Case 0
strBody = "something else"
....

then use

objappt.body = strbody & vbcrlf & inputdata & vbcrlf & inputdata1...
 

George Z

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Thanks Diane. Getting very close. As you stated, this method does seem to be working..... sort of. When run it is populating the aapt.body with both the data from the cobbo box plus the data from the text box. However, regarding the combo box it only pulls the Case 0 strbody which = "subject 1" If I select "subject 2",3,4, or 5 the macro still only grabs "subject 1". Its like it is ignoring the orher selections.

Still researching. Probably right in from of my face. Let me know your thoughts when time permits. Thanks for the assistance as always and happy holidays!
 

George Z

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
I am still coming up short on this. I sure you are sifting through numerous posts. Just wanted to see if you had any time to look into it a bit further as of yet.
 

George Z

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Just checking in, anyone have any additional feedback on this?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
do you have Public lstNo As Long at the very top of the module?
 

George Z

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Public lstNo As Long
Sorry so log getting back to you. Had to back burner this for a minute. I did not have it at the top of the module. However I do now, and all is working as beautifully. Your the woman Diane. Thank you for your continued support and assistance.

I am having a few issues now getting multiple selections from a multi-select list box copied into an appointment however this is beginning a new topic so I will start a new thread on that.
 
Top