在具有默认邮件应用程序的模拟器上一切正常.但是当我收到一封我使用Gmail应用程序从我的Hero发送的邮件时,我没有依恋.英雄的默认邮件应用程序正常工作.
如何使此代码适用于Hero上的Gmail应用?
你可以看到下面的代码.
private void startSendIntent() {
Bitmap bitmap = Bitmap.createBitmap(editableImageView.getWidth(), editableImageView.getHeight(), Bitmap.Config.RGB_565);
editableImageView.draw(new Canvas(bitmap));
File png = getFileStreamPath(getString(R.string.file_name));
FileOutputStream out = null;
try {
out = openFileOutput(getString(R.string.file_name), MODE_WORLD_READABLE);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) out.close();
}
catch (IOException ignore) {}
}
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(png));
emailIntent.setType("image/png");
startActivity(Intent.createChooser(emailIntent, getString(R.string.send_intent_name)));
}
Run Code Online (Sandbox Code Playgroud)
在日志中我看到以下内容:
02-05 17:03:37.526: DEBUG/Gmail(11511): URI FOUND:file:///sdcard/DCIM/100MEDIA/IMAG0001.jpg
02-05 17:03:37.535: DEBUG/Gmail(11511): ComposeActivity added to message:0 …Run Code Online (Sandbox Code Playgroud) 主题可能吗?我有一个脚本正在执行.有一次,我在变量中有一大段文本.我是否可以将其作为可下载文件提供,而无需将可变内容写入磁盘?
<?php
echo "Hello";
//how do I make the content of this variable downloadable?
$download_me = "download me...";
echo "Bye";
?>
Run Code Online (Sandbox Code Playgroud) 默认情况下,保存到内部存储的文件对应用程序是私有的,而其他应用程序无法访问它们(用户也无法访问).
我能够在DDMS中看到文件"/ data/data/package_name/files/in file explore,但是当我在电子邮件中使用imageUri附加上述文件URI时,我看到附件是0kb.我使用了Android的默认电子邮件API.
任何人都可以建议我,如何在应用程序私有的电子邮件中附加文件?
虽然我能成功地将文件保存在SD卡中并从SD卡附加文件,但这很好用.
但是,如果SD卡不可用并将文件保存到内部存储器,那么我如何将它们附加到电子邮件中.
String FILENAME = "hello_file.txt";
String string = "hello world!";FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
File imageFile = getFileStreamPath(FILENAME );
Uri imageUri = Uri.fromFile(imageFile);
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("*/*");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,imageUri);
this.startActivityForResult(Intent.createChooser(emailIntent, "Send mail..."),SUB_ACTIVITY);
Run Code Online (Sandbox Code Playgroud) 我需要在本地安装的胖客户端应用程序(Qt/C++)在客户端的计算机上生成可立即发送的电子邮件:
我已经尝试过了:
mailto:使用链路QDesktopServices::openUrl()与attach(或attachment)参数.但这些参数并不是协议的正式部分,有些客户端(尤其是Outlook)会忽略它们.body参数的一部分添加mailto:.但mailto链接的长度被某些电子邮件客户端(再次,特别是Outlook)截断,因此这不起作用.当您从应用程序中发送图片时,Google Picasa可以实现此目的(至少在Windows上;未检查其他操作系统).它会创建一个包含附件和一些预填充文本的消息.然后,您可以编辑消息并在方便时发送.他们是如何做到这一点的任何想法?
如何在eclipse中将源链接到jar包?
我正在尝试添加外部库ch.ntb.usb.
我将jar文件添加到我的构建路径,但是当我尝试运行应用程序时,它返回了以下错误:
jar文件ch.ntb.usb没有源附件.
我已经使用JD-GUI来反编译jar文件,并且包含了源代码.
我正在尝试让Jenkins将一个文件或一组文件附加到作业已完成的电子邮件通知中.我不断得到一个错误:
发送触发器的电子邮件:成功错误:访问要附加的文件时出错:期望Ant GLOB模式,但看到了C:\p\p\etc\\\*\*\\\*.html.
请参阅文件集语法
是的,我看过那个网站并尝试了我能想到的每一个变化:
/ instead of \
../\*\*
../\*\*/\*.html
removing C:
Run Code Online (Sandbox Code Playgroud)
我在这里缺少什么Ant GLOB模式?
谢谢,斯科特
我google搜索/堆栈溢出了几个小时,没有找到解决这个问题的方法.我想知道我的PaperClip安装是否以某种方式不成功.我正在尝试验证模型文件夹中的图像附件:
validates :image, presence: true,
content_type: { content_type: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif']},
size: { less_than: 5.megabytes }
Run Code Online (Sandbox Code Playgroud)
我也尝试过类似于github上的read me文件的代码:
validates_attachment :image, :presence => true,
:content_type => { :content_type => 'image/jpeg', 'image/jpg', 'image/png', 'image/gif' },
:size => { less_than: => 5.megabytes }
Run Code Online (Sandbox Code Playgroud)
我试图使用个人验证
validates_attachment_presence :image
validates_attachment_content_type :image,:content_type => ['image/jpeg', 'image/jpg', 'image/png', 'image/gif']
validates_attachment_size :image,:less_than => 5.megabytes
Run Code Online (Sandbox Code Playgroud)
在所有情况下我都会收到错误.或者:
Routing Error
undefined method `before_image_post_process' for #<Class:0x00000101461750>
Try running rake routes for more information on available routes.
Run Code Online (Sandbox Code Playgroud)
要么:
NoMethodError in PinsController#index
undefined method `key?' …Run Code Online (Sandbox Code Playgroud) 我的应用程序通过将其传递给URL来呈现.pdf文件(例如,domain.com /letter/2.pdf)
它不会被保存在任何地方.
如何将实际pdf作为出站电子邮件中的附件.
这是我的邮件:
def campaign_email(contact,email)
subject email.subject
recipients contact.email
from 'Me <me@me.com>'
sent_on Date.today
attachment = File.read("http://localhost:3000/contact_letters/#{attachment.id}.pdf")
attachment "application/pdf" do |a|
a.body = attachment
a.filename = "Othersheet.pdf"
end
end
Run Code Online (Sandbox Code Playgroud)
这是创建/呈现PDF的控制器:
def create
@contact_letter = ContactLetter.new(params[:contact_letter])
@contact = Contact.find_by_id(@contact_letter.contact_id)
@letter = Letter.find_by_id(@contact_letter.letter_id)
if @contact_letter.save
flash[:notice] = "Successfully created contact letter."
#redirect_to contact_path(@contact_letter.contact_id)
redirect_to contact_letter_path(@contact_letter, :format => 'pdf')
else
render :action => 'new'
end
end
Run Code Online (Sandbox Code Playgroud)
注意:我硬编码localhost:3000 /如何用变量替换它,以便在dev上它是localhost:3000并且在生产时它是正确的域?有没有办法在此包含路由?)
错误:我得到了
想知道这是否可行.假设电子邮件是用HTML编写的,用于电子邮件客户端呈现.并且HTML代码中存在锚标记,该标记将由电子邮件客户端解析.
可以从服务器外部引用资源(图像,文件等).例如,我可以下载PDF
是否可以引用随电子邮件一起发送的附件?因此,附上PDF并在电子邮件中引用一些标记,该附件是HTML代码的一部分.
我真的不想听到"替代"解决方案.我非常想听到是/否.
我编写了一个应用程序,它从收件箱中获取所有电子邮件,过滤包含特定字符串的电子邮件,然后将这些电子邮件放入ArrayList中.
将电子邮件放入列表后,我正在处理所述电子邮件的主题和内容.这适用于没有附件的电子邮件.但是当我开始使用带有附件的电子邮件时,它们都不能按预期工作了.
这是我的代码:
public void getInhoud(Message msg) throws IOException {
try {
cont = msg.getContent();
} catch (MessagingException ex) {
Logger.getLogger(ReadMailNew.class.getName()).log(Level.SEVERE, null, ex);
}
if (cont instanceof String) {
String body = (String) cont;
} else if (cont instanceof Multipart) {
try {
Multipart mp = (Multipart) msg.getContent();
int mp_count = mp.getCount();
for (int b = 0; b < 1; b++) {
dumpPart(mp.getBodyPart(b));
}
} catch (Exception ex) {
System.out.println("Exception arise at get Content");
ex.printStackTrace();
}
}
}
public void …Run Code Online (Sandbox Code Playgroud)