Hi
i have a command button on a form that creates and outlook email with an attachment. I would like to populate the "to" and "cc" fields of that email with email addresses which are completed on a different form in the database. but i just can't seem to work it out.
I want the "to" field to be populated from a form called "Case Details" and the field is "Manager email"
this is my current code:
Private Sub Command122_Click()
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.Attachments.Add ("C:\Users\Sarah Brown\Documents\Banking info request auth.doc")
.To = ""
.Subject = "Authorisation for banking information request"
.Body = "complete attached file and email to case manager (cc the case inbox)"
.Display
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub
thanks
S
i have a command button on a form that creates and outlook email with an attachment. I would like to populate the "to" and "cc" fields of that email with email addresses which are completed on a different form in the database. but i just can't seem to work it out.
I want the "to" field to be populated from a form called "Case Details" and the field is "Manager email"
this is my current code:
Private Sub Command122_Click()
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.Attachments.Add ("C:\Users\Sarah Brown\Documents\Banking info request auth.doc")
.To = ""
.Subject = "Authorisation for banking information request"
.Body = "complete attached file and email to case manager (cc the case inbox)"
.Display
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub
thanks
S