Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically copying an email message into a DB

Status
Not open for further replies.

newfrontiers

Programmer
Oct 17, 2001
134
US
Hello. I have a form where the user clicks on an email address and MS Outlook opens with the email address in the To box. Once the user completes the email and sends it I would like to have the email message written back to a table (along with other tracking information internal to the DB). Any suggestions?

Thanks.

John

 
newfrontiers,

How are you calling Outlook? With the SendObject method? I think for what you want you will need to dig into the Outlook API, then call an instance of the Outlook object in your code in order to capture the actual text of the message (or, what might be better, the messageID from the message store).

HTH,

Ken S.
 
Thank you for responding. Here is the code I'm using to initiate the email:

If Me.chkEmail = True Then

Dim objMailItem As Outlook.MailItem
Dim varEmailcc As Variant
Dim strEmailcc As String
Dim strSQL2 As String

Set olkApp = New Outlook.Application

Set olkNameSpace = olkApp.GetNamespace("MAPI")
Set objMailItem = olkApp.CreateItem(olMailItem)

strSQL = "Select * from tblUsers WHERE strUser = """ & Me.cboFollowUpTo & """"

rst1.Open strSQL, , adOpenKeyset, adLockPessimistic

For Each varEmailcc In Me.lstEmailcc.ItemsSelected()
strSQL2 = "Select * from tblUsers WHERE strUser = """ & Me.lstEmailcc.ItemData(varEmailcc) & """"
rst2.Open strSQL2, , adOpenKeyset, adLockPessimistic
strEmailcc = strEmailcc & rst2.Fields("strEmail") & ";"
rst2.Close
Next varEmailcc

Debug.Print "frmcontactinfo | Add comment | Email cc list: " & strEmailcc

With objMailItem
Debug.Print "Comment to send: " & Me.txtComment
.To = rst1.Fields("strEmail")
.Subject = "Activity #: " & int1 & " issued by: " & userid
.CC = strEmailcc
.Body = "Client: " & Me.BusName & Chr(10) & "Follow Up Date: " & Me.txtFollowUp & Chr(10) & "Comment: " & Me.txtComment
.Display
If Not IsNull(Me.chkUrgEmail) Then .Importance = olImportanceHigh
.Send
Debug.Print "Email sent to " & rst1.Fields("strEmail") & " for Activity #: " & int1
End With

Set objMailItem = Nothing
Set olkNameSpace = Nothing
Set olkApp = Nothing

Else

Exit Sub

End If

Any help is appreciated.

Thanks,

John

 
Since you are in the db and you build the body
(.Body = "Client: " & Me.BusName & Chr(10) & "Follow Up Date: " & Me.txtFollowUp & Chr(10) & "Comment: " & Me.txtComment)

Then why dont just run an append statment at the end of your code.

insert it right after the .Send line.


Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
abaldwin, thank you for the reply. I'm going to give this a try.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top