所以这是我一直试图解决的场景。一个用户来到我们的网站,上传一个文件,该文件被发送到一个谷歌文档集合并生成一个指向该文档的链接,该链接通过电子邮件发送给管理员。我有一个公告页面,我想通过此脚本自动更新,以在公告中包含指向文档的链接......这是代码
function newAnnouncement(parameter){
var site = SitesApp.getPageByUrl("https://sites.google.com/a/westcongps.com/dhcorpintranettestsite/company-blog");
site.createAnnouncement("this is the title", '<a href="' + parameter + '">LINK TEXT</a>');
}
function doGet(e) {
// creates the ui application
var app = UiApp.createApplication();
// set's up the application user interface.
var form = app.createFormPanel().setId('frm').setEncoding('multipart/form-data');
var formContent = app.createVerticalPanel();
form.add(formContent);
var fileUp = app.createFileUpload().setName('thefile');
var submit = app.createSubmitButton('Submit');
formContent.add(fileUp);
formContent.add(submit);
app.add(form);
submit.setPixelSize(75, 20);
return app;
}
function doPost(e) {
// data returned is a blob for FileUpload widget
var fileBlob = e.parameter.thefile;
var doc = DocsList.createFile(fileBlob);
//var to store the folder the file will be uploaded to
var folder = DocsList.getFolder("collection");
//adds the document to the folder ^^^
doc.addToFolder(folder);
var emailAddress = "me@example.com";
var subject = "subject";
var body = "A new quote has been requested, please process the attachment";
// send a notification email with attached file or link to uploaded file
//gets the URL of the uploaded document
var docUrl = doc.getUrl();
//adds the body text to the doc url to create the body message
var bodyUrl = body + "\n" + docUrl;
// gets the page I would like to post the announcement on
var site = SitesApp.getPageByUrl("http://example.com/announcements-page");
site.createAnnouncement("this is the title", '<a href="linkToGoogleDoc">LINK TEXT</a>');
MailApp.sendEmail(emailAddress, subject, bodyUrl);
app.close();
return app;
}
有人可以帮我"docUrl"
进入公告吗?谢谢你。
newAnnouncement(parameter)
可以忽略该功能,以防万一它可以帮助您帮助我:)