Question

Thanks in advance. The scenario is: When a new email is created containing an address pre-populated in the "To" field then clicking a custom form button, copy that email into the custom form's "To" field and close the original new email. (essentially replacing the original regular email with the form pre-populated with the original "To" address).

The Custom form is working fine but I'm confused on how to talk to or pull the data from that first email to the form when the form opens.

Was it helpful?

Solution 2

I've modified the Macro that opens my custom form. I've added a button to the quick launch toolbar that appears on every email. The Macro gets the address in the To field of email #1, launches the custom form, places the address into the To field of the custom form, then closes the original (email #1).

Public Sub ComplexCustomForm()
 Dim olfolder As Outlook.MAPIFolder
 Dim olapp As Outlook.Application
 Dim Items As Outlook.Items
 Dim Item As Object
 Dim m As mailItem

 Set m = ActiveInspector.CurrentItem
 f = m.To
 Set olapp = CreateObject("Outlook.Application")
 Set olfolder = olapp.GetNamespace("Mapi").folders("SHARED FOLDER WHERE IPM.Note RESIDES")

 Set Items = olfolder.Items
 Set Item = Items.Add("IPM.Note.ComplexCustomForm")
 Item.Display
 Item.To = f
 m.Close olDiscard

 Set m = Nothing
 Set olfolder = Nothing
 Set olapp = Nothing
 Set Items = Nothing
 Set Item = Nothing
End Sub

OTHER TIPS

Loop through the MailItem.Recipients collection, read each recipient's Name and Address property, call MailItem.Recipients.Add on the new message. In case of SMTP addresses, pass "Name " to Recipeints.Add, in case of EX addresses pass just the EX address.

You can also try to read PR_ENTRYID, PR_DISPLAY_NAME, PR_EMAIL_ADDRESS properties using Recipient.PropertyAccessor and set them on the new message using Recipient.PropertyAccessor.SetProperty to make sure the recipients are resolved and look exactly like the original message.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top