Can access automatically insert "from" field when sending email

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

I have the following code:
rivate Sub ComdSendRes_Click()
Dim strSubject As String
Dim strEmailList As String
Dim strMessage As String
Dim strmess2 As Boolean

strmess2 = True

On Error GoTo Err_ComdSendRes_Click

strSubject = "Sending test email: "
strEmailList = "(e-mail address removed)"
strMessage = "Description: " & Me.Ticket_Description & Chr(13) & "Assign
to: " & [Assigned To] & Chr(13) & "Resolution: " & [Resolution]
DoCmd.SendObject acSendNoObject, , acFormatRTF, strEmailList, , ,
strSubject, strMessage, strmess2

How can I modify this code so everytime from field with my email address is
inserted when i am ready to send email?

Thanks
 
I have the following code:
rivate Sub ComdSendRes_Click()
Dim strSubject As String
Dim strEmailList As String
Dim strMessage As String
Dim strmess2 As Boolean

strmess2 = True

On Error GoTo Err_ComdSendRes_Click

strSubject = "Sending test email: "
strEmailList = "(e-mail address removed)"
strMessage = "Description: " & Me.Ticket_Description & Chr(13) &
"Assign
to: " & [Assigned To] & Chr(13) & "Resolution: " & [Resolution]
DoCmd.SendObject acSendNoObject, , acFormatRTF, strEmailList, , ,
strSubject, strMessage, strmess2

How can I modify this code so everytime from field with my email address
is inserted when i am ready to send email?

Thanks

The FROM field in Email messages is for when you want to specify somebody
besides yourself. If you just want the Email to look like it was from
YOU then that will happen automatically without filling in the FROM field.
 
You can't, but if you've set up your default email client with a from
address, it should automatically fill in.
 
Greg,

If you're using Outlook you can set the FROM address by using
..SentOnBehalfOfName
In the example beneath you see how this property is set by using the string
strFrom.
Btw: you need the MS Outlook reference to be checked.
But like Arvin said, if you don't set the FROM address, the default address
will be used.

John


Public Sub sendMail(strFrom As String, _
strTo As String, _
strCC As String, _
strSubj As String, _
strBody As String, _
booUrg As Boolean, _
Optional booDispl As Boolean = True)

Dim outApp As Outlook.Application
Dim outMsg As MailItem

On Error GoTo Err_Handler

Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
With outMsg
.SentOnBehalfOfName = strFrom
.To = strTo
.CC = strCC
.Subject = strSubj
.Body = strBody
If booUrg Then
.Importance = olImportanceHigh
End If
If booDispl Then
.Display
Else
.Send
End If
End With

Exit_This_Sub:
Set outApp = Nothing
Set outMsg = Nothing
Exit Sub
Err_Handler:
MsgBox "Error# " & Err.Number & " " & Err.Description
Resume Exit_This_Sub
End Sub
 
Back
Top