Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- powershell -command "& { . C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1; SendGmail "<email address>" "subject" "body" }"
- PRINT 'Use the Divestar database'
- USE [Divestar]
- GO
- PRINT 'Grant access to execute through a kind of cmd'
- EXEC sp_configure 'show advanced options', 1
- GO
- RECONFIGURE
- GO
- EXEC sp_configure 'xp_cmdshell', 1
- GO
- RECONFIGURE
- GO
- -- Delete the old procedure
- PRINT 'Drop procedure'
- DROP PROCEDURE IF EXISTS [dbo].[SendEmail]
- GO
- -- Procedure --
- PRINT 'Create procedure to send an email'
- GO
- CREATE PROCEDURE [dbo].[SendEmail]
- @To VARCHAR(1024),
- @Subject VARCHAR(1024),
- @Content VARCHAR(1024)
- AS
- BEGIN
- DECLARE @CMD VARCHAR(1024)
- SET @CMD = 'powershell -command "& { . "C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1"; SendGmail "<email address>" "onderwerp" "bodytje" }"'
- PRINT @CMD
- EXEC xp_cmdshell @CMD
- END
- GO
- . : The term
- 'C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1' is not
- recognized as the name of a cmdlet, function, script file, or operable
- program. Check the spelling of the name, or if a path was included, verify
- that the path is correct and try again.
- At line:1 char:7
- + & { . C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1;
- Send ...
- + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- + CategoryInfo : ObjectNotFound: (C:Usersmslaat...mailLibrary.p
- s1:String) [], CommandNotFoundException
- + FullyQualifiedErrorId : CommandNotFoundException
- SendGmail : The term 'SendGmail' is not recognized as the name of a cmdlet,
- function, script file, or operable program. Check the spelling of the name, or
- if a path was included, verify that the path is correct and try again.
- At line:1 char:77
- + & { . C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1;
- Send ...
- +
- ~~~~
- + CategoryInfo : ObjectNotFound: (SendGmail:String) [], CommandNo
- tFoundException
- + FullyQualifiedErrorId : CommandNotFoundException
- NULL
Add Comment
Please, Sign In to add comment