megatronixs
Registered User.
- Local time
- Today, 16:04
- Joined
- Aug 17, 2012
- Messages
- 719
Hi all,
I wanted to create a automation to send invitation out for users on a list for the training.
It seems hard to implement.
I could get only 2 users on a list to the email and the body of the email was empty.
after many attempts, it is still giving me nothing that works.
The idea is that it will loop trough a table where all the users are, add them to the attendees list (this does not work, only the recipients), then create the body and add all the data into the invitation and display it before sending.
please find below the code that is more mixed up than anything else.
(the text in the email is only to test)
Greetings.
I wanted to create a automation to send invitation out for users on a list for the training.
It seems hard to implement.
I could get only 2 users on a list to the email and the body of the email was empty.
after many attempts, it is still giving me nothing that works.
The idea is that it will loop trough a table where all the users are, add them to the attendees list (this does not work, only the recipients), then create the body and add all the data into the invitation and display it before sending.
please find below the code that is more mixed up than anything else.
Code:
Private Sub btn_send_invitation_Click()
Dim objItem As Object
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim outMail As Outlook.AppointmentItem
Dim outMail2 As Outlook.MailItem
Dim oApp As Object
Set outMail = objItem
Set oApp = CreateObject("Outlook.application")
Set outMail2 = oApp.CreateItem(olMailItem)
Set db = CurrentDb()
Set MailList = db.OpenRecordset("My_Email_Addresses")
Set outMail = Outlook.CreateItem(olAppointmentItem)
Do Until MailList.EOF
' This creates the e-mail
' We need to move it BEFORE we start the loop, since
' we don't want to make a bunch of e-mails, we just want one.
' this is where we loop through our list of addresses,
' and we add them to the RECIPIENTS collection
' This adds the address to the list of recipients
'And on to the next one...
MailList.MoveNext
Loop
Do Until MailList.EOF
'//-------------------------------------------------------------------------------------------
outMail.Recipients.Add MailList("UserEmail")
Loop
outMail.Subject = Me.training_name
outMail.location = Me.training_location_text
outMail.MeetingStatus = olMeeting
outMail.start = Me.start_date_text & " " & Me.training_time_start
outMail.End = Me.end_date_text & " " & Me.training_end_time
outMail2.HTMLBody = "<HTML><HEAD><Font Size= 4><style> table, th, td </style> </HEAD> <BODY><br><p>" & _
"*** This is an automatically generated email, please do not reply ***<br><br>" & _
"Please note that: " & MailList("Forename") & " " & MailList("Surname") & "<br><br>" & _
"Date: " & Me.start_date_text & "<br>" & _
"Locatoin: " & Me.training_location_text & " <br>" & _
"Start Time: " & Me.start_time_text & " <br>" & _
"End Time: " & Me.end_time_text & " <br>" & _
"this in the invitation info.<br><br>" & _
"If you have any questions please contact us.br><br></BODY> </HTML>"
outMail.Display
'Loop
Set outMail = Nothing
End Sub
Greetings.