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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specifying the 'From' field in Emails from Access 1

Status
Not open for further replies.

Sacheveral

Technical User
Jan 24, 2005
23
GB
I have a routine that sends emails from Access, but I want to specify the 'From' field in the email and it will not seem to let me. Does anyone have any suggestions? The code is:

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook
.To = Recips
.From = FromAddress
.Subject = Subject
.Body = Message
.Attachments.Add (FileName)
.Send
End With

For reference my main email account is an Exchange Server, and the account I want to send from (for which I do have 'send from' permissions) is list listed as an additional mailbox.

Many thanks,

Joe
 
You may have to Logon with your sender profile.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Joe

This is the sort of thing that works for me -

Private Sub cmdEmail_Click()
On Error Resume Next

Dim strBody As String, strSubject As String
strSubject = Me.YourField

strBody = "Your message " & Me.YourField2 & " More of your message.”

'DoCmd.SendObject , , , "FromAddress", , , strSubject, strBody
DoCmd.SendObject , , , "WhoIt’sToAddress", "CopiesToAddress", strSubject, strBody

Exit_cmdSendEmail_Click:
Exit Sub

End Sub

hth
 
OOPs, rather this ...

Private Sub cmdEmail_Click()
On Error Resume Next

Dim strBody As String, strSubject As String
strSubject = Me.YourField

strBody = "Your message " & Me.YourField2 & " More of your message.”


DoCmd.SendObject , , , "WhoIt’sToAddress", "CopiesToAddress", strSubject, strBody

Exit_cmdSendEmail_Click:
Exit Sub

End Sub
 
Thanks for that, but unfortunately (at least as far as I can tell) you cannot add file attachments using the SendObject command, which is why I used the Outlook application method.

I cannot log in as that account, I can just send email from it, and I do not want to go in and change it manually to be the primary email account as I have to run this every morning and it would take ages to keep configuring Outlook, unless of course it can be done automatically....

All help appreciated,

Thanks,

Joe
 
I talked about the Outlook's NameSpace.Logon method ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top