How would you greet someone in a formal way?

To greet someone in a formal way, you could use a proper and respectful salutation, say something like: "Good morning/afternoon/evening, [title and name]. It's a pleasure to see/meet you."