megatronixs
Registered User.
- Local time
- Today, 18:42
- Joined
- Aug 17, 2012
- Messages
- 719
Hi all,
I have code that will create an email and prepare it for sending.
It will create a table inside the email and fill it in with some text and underscore characters to be replaced by data from the database. So far the data has to be done manually. I would like to know if it is possible to use the values from some fields inside the select record in the current form. So, if Me.Status would be "New" it should pass this to the table in the email.
So far I have the below code:
Greetings.
I have code that will create an email and prepare it for sending.
It will create a table inside the email and fill it in with some text and underscore characters to be replaced by data from the database. So far the data has to be done manually. I would like to know if it is possible to use the values from some fields inside the select record in the current form. So, if Me.Status would be "New" it should pass this to the table in the email.
So far I have the below code:
Code:
[SIZE=3][FONT=Calibri]Private Sub Command280_Click() 'send email with table[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Dim objItem As Object[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Dim oMail As Outlook.MailItem[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Set oMail = objItem[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Dim oApp As Object[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Dim BIN As String ‘field Me.BIN[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Dim Name As String ‘field Me.Name[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Dim Rating As String ‘field Me.Rating[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Dim Status As String ‘field Me.Status[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Set oApp = CreateObject("Outlook.application"[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Set oMail = oApp.CreateItem(olMailItem)[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] oMail.HTMLBody = "<html> <head> <Font Size= 1><style> table, th, td </style> </head> <body> <br><br><br><br><br><br><p>Dear reader,</p><p>it is important that the table is not altered in any other way.<br>Changes can only be made for the status.</p><p>Regards</p> <TABLE><TR><TD>Rating:</TD><TD>-----</TD></TR><TR><TD>BIN nr:</TD><TD>-----</TD></TR><TR><TD>Name:</TD><TD>-----</TD></TR><TR><TD>Status:<TD> & Me.Status &</TD></TABLE> </body> </html>"[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] oMail.Subject = "Status on case with BIN nr: "[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] oMail.To = ""[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] oMail.BodyFormat = 3[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] oMail.Display[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Debug.Print Risk_Rating[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Set oMail = Nothing[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] Set oApp = Nothing[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]End Sub[/FONT][/SIZE]
Greetings.