Hi All,
We have gone to a paperless phone message system as part of the db I am developing. A record is entered into the db by the receptionist and when she clicks on a command button it sends the message to the recipient using Outlook. I am using the following code to invoke a blank email in Outlook, copy some info from fields in the form, and send it to the recipient. It works great, with one exception. The "Comment" field on the form is a memo field. (It used to be a text field but was not suitable for longer messages.) What happens is this: When the cmd button is clicked, all fields are transferred properly to the email except the Comment (Note). It defaults to the "No message" text, even when there is a message. If the receptionist closes the email before sending it then clicks on the cmd button again, the proper message is imported into the email.
One other thing. There is a "Taken by" field on the form which grabs the user name automatically and saves it with the record. When the email is invoked the second time (to include the proper message), the "Taken By" name changes from the receptionist's name to the default "Other".
I hope this is clear. Please ask for clarification if not.
Thanks a bunch!
TechieJr.
We have gone to a paperless phone message system as part of the db I am developing. A record is entered into the db by the receptionist and when she clicks on a command button it sends the message to the recipient using Outlook. I am using the following code to invoke a blank email in Outlook, copy some info from fields in the form, and send it to the recipient. It works great, with one exception. The "Comment" field on the form is a memo field. (It used to be a text field but was not suitable for longer messages.) What happens is this: When the cmd button is clicked, all fields are transferred properly to the email except the Comment (Note). It defaults to the "No message" text, even when there is a message. If the receptionist closes the email before sending it then clicks on the cmd button again, the proper message is imported into the email.
One other thing. There is a "Taken by" field on the form which grabs the user name automatically and saves it with the record. When the email is invoked the second time (to include the proper message), the "Taken By" name changes from the receptionist's name to the default "Other".
I hope this is clear. Please ask for clarification if not.
Thanks a bunch!
TechieJr.
Code:
Private Sub SendEMail_Click()
Dim CallerName As String, Comp As String, BusPh As String, Called As String, _
contype As String, FolUp As String, Note As String, WhenD As String, WhenT As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
CallerName = Forms![f_DayLogEntry]!Callname.Column(1)
Comp = Nz(Forms![f_DayLogEntry]!Company, "No company")
BusPh = Nz(Forms![f_DayLogEntry]!BusPhone, "No phone")
Called = Me!CalledFor.Column(1)
Note = Nz(Me!Comment, "No message")
WhenD = Me!NewDate
WhenT = Me!NewTime
Select Case Me!ContactType
Case 3
contype = "Visitor came to see"
Case 2
contype = "Came for meeting with"
Case Else
contype = "Phone call for"
End Select
Select Case Me!Action
Case 4
FolUp = "Returned your call."
Case 3
FolUp = "Will call back."
Case 2
FolUp = "Please call."
Case Else
FolUp = "No action required."
End Select
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = Called
.Subject = contype & " " & Called
.Body = CallerName & " of " & Comp & " (" & BusPh & ") " & Chr(13)
.Body = .Body & "At " & WhenT & " on " & WhenD & Chr(13)
.Body = .Body & FolUp & Chr(13)
.Body = .Body & Note
.Display
End With
Set objEmail = Nothing
Me!CalledFor.SetFocus
Forms![f_DayLogEntry]!CallName.SetFocus
PlayWave ("c:\windows\media\windows XP ringin.wav")
End Sub