dependencies {
[...]
compile(group: 'com.google.oauth-client', name: 'google-oauth-client', version: rootProject.ext.GOOGLE_API_CLIENT_VERSION)
/////////////////////////////////
// Google Play Services explicit dependency
compile(group: 'com.google.android.gms', name: 'play-services-auth', version: rootProject.ext.GOOGLE_PLAY_SERVICES_VERSION)
compile(group: 'com.google.android.gms', name: 'play-services-plus', version: rootProject.ext.GOOGLE_PLAY_SERVICES_VERSION)
[...]
/////////////////////////////////
// Local Testing
testCompile(group: 'junit', name: 'junit', version: rootProject.ext.JUNIT_VERSION)
testCompile(group: 'pl.pragmatists', name: 'JUnitParams', version: rootProject.ext.JUNIT_PARAMS_VERSION)
[...]
}
我正在尝试使用google驱动器发送带有jpg文件的电子邮件,但它不起作用。请帮帮我。
答案 0 :(得分:0)
从此Google documentation开始,attachments
参数应为BlobSource[]
类型,并且是随电子邮件发送的文件数组。
文档中的示例:
// Send an email with two attachments: a file from Google Drive (as a PDF) and an HTML file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var blob = Utilities.newBlob('Insert any HTML content here', 'text/html', 'my_document.html');
MailApp.sendEmail('mike@example.com', 'Attachment example', 'Two files are attached.', {
name: 'Automatic Emailer Script',
attachments: [file.getAs(MimeType.PDF), blob]
});
检查此代码是否适合您:
function pic()
{
var userEmail = "sikrarin.pooh@gmail.com";
var firstName ="test";
var Subject = "test"
var file = DriveApp.getFileById('0B1j-ntZn6vurRkZVVEpxWmRGSlU');
MailApp.sendEmail(userEmail, Subject{
attachment:[file,blob]
});
}
希望这有帮助!