MenuQueries LibrarySend an email to the admin notifying of a new postSend an email to the admin notifying of a new postThis query sends an email to the admin user, notifying of the creation of a new post on the site: query GetPostAndExportData($postId: ID!) { post(by: { id: $postId }, status: any) { content @export(as: "postContent") title @export(as: "postTitle") url @export(as: "postURL") } } query GetEmailData @depends(on: "GetPostAndExportData") { adminEmail: optionValue(name: "admin_email") @export(as: "adminEmail") emailMessageTemplate: _strConvertMarkdownToHTML( text: """ There is a [new post on the site]({$postURL}): **{$postTitle}**: {$postContent} """ ) emailMessage: _strReplaceMultiple( search: ["{$postTitle}", "{$postContent}", "{$postURL}"], replaceWith: [$postTitle, $postContent, $postURL], in: $__emailMessageTemplate ) @export(as: "emailMessage") emailSubject: _sprintf( string: "New post: \"%s\"", values: [$postTitle] ) @export(as: "emailSubject") } mutation SendEmailToAdminAboutNewPost @depends(on: "GetEmailData") { _sendEmail( input: { to: $adminEmail subject: $emailSubject messageAs: { html: $emailMessage } } ) { status } }CopyPrevSend an email to the adminNextSend an email using Markdown
This query sends an email to the admin user, notifying of the creation of a new post on the site: query GetPostAndExportData($postId: ID!) { post(by: { id: $postId }, status: any) { content @export(as: "postContent") title @export(as: "postTitle") url @export(as: "postURL") } } query GetEmailData @depends(on: "GetPostAndExportData") { adminEmail: optionValue(name: "admin_email") @export(as: "adminEmail") emailMessageTemplate: _strConvertMarkdownToHTML( text: """ There is a [new post on the site]({$postURL}): **{$postTitle}**: {$postContent} """ ) emailMessage: _strReplaceMultiple( search: ["{$postTitle}", "{$postContent}", "{$postURL}"], replaceWith: [$postTitle, $postContent, $postURL], in: $__emailMessageTemplate ) @export(as: "emailMessage") emailSubject: _sprintf( string: "New post: \"%s\"", values: [$postTitle] ) @export(as: "emailSubject") } mutation SendEmailToAdminAboutNewPost @depends(on: "GetEmailData") { _sendEmail( input: { to: $adminEmail subject: $emailSubject messageAs: { html: $emailMessage } } ) { status } }Copy