I have an Excel worksheet where I can insert Data into a MS SQL Database. When closing this worksheet, a mail with the sql-script attached should be generated and send automatically. The script includes all the create table, sequences and insert statements.
I can generate the sql script manually in the MS SQL Studio, but maybe there´s a method (here: generate_sql_script) to generate the script automatically.
Here´s my code for generating the mail:
Dim objOutlook, objMail, sql_Script As Object
Set objOutlook = CreateObject("Outlook.Application")
sql_Script = generate_sql_script
With objMail
.To = "myEmail@test.com"
.Subject = "new sql script attached"
.Body = "Dear Sir or madam..."
.Attachments.Add sql_Script
.Send
End With
Thanks for any help in advance.