Back again... I have managed to get my form working and formatted quite well. I am stuck on one part. The following is the code I am using...
Now instead of a static email address in the .to I would like to pull email addresses from the database seperated by ; and being ok with null values.
I can potenially collect 3 email addresses and they go into 3 fields in the database. i want to pull all of the availble addresses and format them for outlook. I tried calling them similarly to how I called the information in my database but I cant get it to work. Could someone point me in the right direction?
Code:
Private Sub Command25_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
.BodyFormat = olFormatRichText
.To = "[EMAIL="slove19_2000@yahoo.com"]slove19_2000@yahoo.com[/EMAIL]"
.Subject = "Your inspection has been scheduled."
.Body = "Greetings " & Format(DLookup("Contact_Information_FirstName", "Inspection", "[requests_InspectionID]=" & Chr(34) & Me!requests_InspectionID & Chr(34)), " ") & " " & Format(DLookup("Contact_Information_LastName", "Inspection", "[requests_InspectionID]=" & Chr(34) & Me!requests_InspectionID & Chr(34)), "") & " your inspection has been scheduled for " & Format(DLookup("InspectionDate", "Inspection", "[InspectionID]=" & Me!Inspection_InspectionID), "mmmm d, yyyy") & " at " & Format(DLookup("InspectionTime", "Inspection", "[InspectionID]=" & Me!Inspection_InspectionID), " hh:mm AMPM ") & " at the following address; " & NZ(DLookup("SiteAddress", "Inspection", "[SiteAddress]=" & Chr(34) & Me!SiteAddress & Chr(34)), "") & ". If you have any questions or concerns please feel free to contact us." & vbCrLf & vbCrLf & "Thank you," & vbCrLf & "Kurt Nelson" & vbCrLf & "Winding River Home Inspection Services LLC." & vbCrLf & "970-222-2104 or 303-774-1104"
.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
Now instead of a static email address in the .to I would like to pull email addresses from the database seperated by ; and being ok with null values.
I can potenially collect 3 email addresses and they go into 3 fields in the database. i want to pull all of the availble addresses and format them for outlook. I tried calling them similarly to how I called the information in my database but I cant get it to work. Could someone point me in the right direction?