CREATE TABLE [dbo].[OutgoingEmail]
(
[OutgoingEmailID] [int] NOT NULL IDENTITY(1, 1),
[FromAddress] [nvarchar] (120) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[FromName] [nvarchar] (120) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ReplyToAddress] [nvarchar] (120) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ReplyToName] [nvarchar] (120) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Subject] [nvarchar] (998) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[EmailContent] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BodyFormat] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[EstimatedByteLength] [int] NULL,
[SysUserFID] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmail] ADD CONSTRAINT [CK_OutgoingEmail_BodyFormat] CHECK (([BodyFormat]='TEXT' OR [BodyFormat]='HTML'))
GO
ALTER TABLE [dbo].[OutgoingEmail] ADD CONSTRAINT [PK_OutgoingEmailID] PRIMARY KEY CLUSTERED ([OutgoingEmailID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OutgoingEmail_SysUserFID] ON [dbo].[OutgoingEmail] ([SysUserFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmail] ADD CONSTRAINT [FK_OutgoingEmail_SysUser] FOREIGN KEY ([SysUserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID]) ON DELETE SET NULL
GO
GRANT SELECT ON [dbo].[OutgoingEmail] TO [MssExec]
GRANT INSERT ON [dbo].[OutgoingEmail] TO [MssExec]
GRANT DELETE ON [dbo].[OutgoingEmail] TO [MssExec]
GRANT UPDATE ON [dbo].[OutgoingEmail] TO [MssExec]
GO