I am trying to capture the data (To, From, Subject and Message) from an outgoing email from MS Outlook. The data capture will be sent to a web page by GET method.
The below code is initiated when the user click the Macro button 'Send and Add'. As soon as the user click the Macro the data must be captured and send to the web page and than send the email. The only problem is that when there is a ; (semi colon) in the 'To:' field i can't get the Email address. I tried to Replace the ; using Replace() function but it doesn't work.
Any idea would be helpful.
----------------- ~~~~~ -----------------
Code:
Sub SENDandADD()
Dim MailTo As String
Dim MailFrom As String
Dim MailSubject As String
Dim MailMessage As Variant
Set objOutlook = CreateObject("Outlook.Application")
Set objItem = objOutlook.ActiveInspector.CurrentItem
'CAPTURE THE DATA
MailTo = objItem.To
MailFrom = "Jack Nick"
MailSubject = objItem.Subject
MailMessage = objItem.Body
'REPLACE THE ; FROM THE TO FIELD
MailTo = Replace(MailTo, ";", "")
MsgBox (MailTo)
'THE WEBSITE TO GO
Dim URL
URL = "www.some-website.com"
'ONLY FOR IE
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 1
'PASS THE CAPTURED DATA BY GET METHOD
IE.navigate ("http://" + URL + "?toEmail=" + MailTo + "&fromEmail=" + MailFrom + "&subject=" + MailSubject + "&message=" + MailMessage)
'SEND EMAIL
objItem.Send
End Sub
