Hi Guy's, can anyone correct this following function ? the MsgBox for Email Address is returning blank and the MsgBox for client is returning > from Website has been filled out < instead of the mail body ? the from Website has been filled is more like the subject or header, the txtClientMessage does have an enquiry in with name and email address etc from the GrabMail function
Email grabbed and pasted works great.
it is the ExtractMailBody that doesn't appear to grab correct data
Code:
Public Function GrabMail() As StringDim WordApp As Word.Application
Dim MailBody As MailItem
If TypeName(ActiveExplorer.Selection.Item(1)) = "MailItem" Then
Set MailBody = ActiveExplorer.Selection.Item(1)
MailBody.GetInspector().WordEditor.Range.FormattedText.Copy
Forms!frmMainMenu!txtClientMessage = MailBody
End If
End Function
Code:
Public Function ExtractMailBody() As StringDim MailBody As String, EmailTbox As String
Dim CLName() As String, EmailAdd() As String
Dim a As Long, b As Long
MailBody = Forms!frmMainMenu!txtClientMessage
CLName = Split(MailBody, vbCrLf)
For a = 0 To UBound(CLName)
If InStr(1, CLName(a), "*Name:") > 0 Then
Forms!frmMainMenu!txtClient = Mid(CLName(a), 7)
End If
MsgBox (Mid(CLName(a), 7))
Next a
EmailAdd = Split(MailBody, vbCrLf)
For b = 0 To UBound(EmailAdd)
If InStr(1, EmailAdd(b), "*Email Address:") > 0 Then
EmailTbox = Mid(EmailAdd(b), 17)
Forms!frmMainMenu!txtClient = EmailTbox
End If
MsgBox (EmailTbox)
Next b
End Function