标签: attachment

将文件附加到python中的电子邮件会导致空白文件名?

下面的代码片段工作正常,除了电子邮件中生成的附件文件名是空白的(该文件在gmail中打开为'noname').我究竟做错了什么?

file_name = RecordingUrl.split("/")[-1]
            file_name=file_name+ ".wav"
            urlretrieve(RecordingUrl, file_name)

            # Create the container (outer) email message.
            msg = MIMEMultipart()
            msg['Subject'] = 'New feedback from %s (%a:%a)' % (
From, int(RecordingDuration) / 60, int(RecordingDuration) % 60)

            msg['From'] = "noreply@example.info"
            msg['To'] = 'user@gmail.com'
            msg.preamble = msg['Subject']                
            file = open(file_name, 'rb')
            audio = MIMEAudio(file.read())
            file.close()
            msg.attach(audio)

            # Send the email via our own SMTP server.
            s = smtplib.SMTP()
            s.connect()
            s.sendmail(msg['From'], msg['To'], msg.as_string())
            s.quit()
Run Code Online (Sandbox Code Playgroud)

python email filenames attachment

10
推荐指数
1
解决办法
4332
查看次数

通过GMailSender发送带附件的电子邮件?

我一直在阅读博客并尝试了大量的实现,但仍未能将图像附加到我通过GMail使用java发送的电子邮件中.我下载了所有的罐子并添加了GMailSender.java,GMailAuthenticator.java和JSSEProvider.java,我能够定期发送常规电子邮件.我尝试过的方式如下所示,中间部分被注释为我希望添加图像的部分.下面是我尝试执行此操作时logcat上的输出.当然,我错过了一些非常简单的事情.有人能指出我吗?提前致谢.

    public synchronized void sendMail(String subject, String body, String sender, String recipients) throws Exception {  
        try {  
            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());  
        MimeMessage message = new MimeMessage(session);  
        DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));  
        message.setSender(new InternetAddress(sender));  
        message.setSubject(subject);  
        message.setDataHandler(handler);  

        /*  
        // Create your new message part  
        BodyPart imgPart = new MimeBodyPart();  

        // Create a related multi-part to combine the parts  
        MimeMultipart multipart = new MimeMultipart("related");  
        multipart.addBodyPart(imgPart);

        String fileName = "http://.../sampleBarcode.png";  

        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();  
        if (classLoader == null) {  
                classLoader = this.getClass().getClassLoader();  
            if (classLoader == …
Run Code Online (Sandbox Code Playgroud)

gmail android attachment javax.mail

10
推荐指数
1
解决办法
5205
查看次数

如何使用Javascript将当前页面下载为文件/附件?

我知道这里提到的隐藏的iFrame技巧(http://stackoverflow.com/questions/365777/starting-file-download-with-javascript)和其他答案.

我对类似的问题很感兴趣:

我如何使用Javascript下载当前页面(IE:当前DOM或其​​中的一些子集)作为文件?

我有一个网页,它从非确定性查询中获取结果(例如随机样本)以显示给用户.我已经可以通过查询字符串参数使页面返回文件而不是呈现页面.我可以添加"获取文件版本"按钮(我们的标准方法),但结果将与显示的结果不同,因为它是查询的不同运行.

有没有办法通过Javascript下载当前页面作为文件,或复制到剪贴板我唯一的选择?

编辑 Stefan Kendall和dj_segfault建议的选项是编写结果服务器端以供以后检索.好主意,但遗憾的是在这种情况下写文件服务器端是不可能的.

如何不寒而栗传递innerHTML的参数后到另一个页面?

javascript attachment download

10
推荐指数
2
解决办法
2万
查看次数

处理附件以响应GWT中的RequestBuilder

我正在从GWT客户端向HTTPServlet发出HTTP POST请求.此Servlet正在从请求内容创建PDF文件并将其写入响应流.

响应流的标头是:

Content-Disposition: attachment; filename=report.pdf
Run Code Online (Sandbox Code Playgroud)

我想在用户浏览器的新窗口中打开此PDF或提示他下载它.

import com.google.gwt.http.client.*;
...

String url = "http://www.myserver.com/getData?type=3";
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));

try {
  Request request = builder.sendRequest(data, new RequestCallback() {
    public void onError(Request request, Throwable exception) {
       // Couldn't connect to server (could be timeout, SOP violation, etc.)     
    }

    public void onResponseReceived(Request request, Response response) {
      if (200 == response.getStatusCode()) {
          // Process the response in response.getText()
          // Window.open(url, "_blank", "");
      } else {
        // Handle the error.  Can get the …
Run Code Online (Sandbox Code Playgroud)

java pdf gwt attachment

10
推荐指数
1
解决办法
8286
查看次数

如何检测用户何时成功完成在php中下载文件

我有一个php页面来处理文件下载的请求.我需要能够检测文件何时成功下载.如何才能做到这一点?也许有一些方法可以检测到这个客户端,然后向服务器发送确认信息.

谢谢.

编辑:通过句柄,我的意思是该页面正在做这样的事情:

$file = '/var/www/html/file-to-download.xyz';
  header('Content-Type: application/octet-stream');
  header('Content-Length: ' . filesize($file));
  header('Content-Disposition: attachment; filename=' . basename($file));
  readfile($file);
Run Code Online (Sandbox Code Playgroud)

php attachment http-headers

9
推荐指数
1
解决办法
7452
查看次数

如何获取我的Rails应用程序的基本URL(例如http:// localhost:3000)?

我正在使用Paperclip来允许用户附加内容,然后我发送电子邮件并希望将该文件附加到电子邮件中.我正在尝试读取该文件并将其添加为附件,如下所示:

# models/touchpoint_mailer.rb
class TouchpointMailer < ActionMailer::Base
  def notification_email(touchpoint)
    recipients "me@myemail.com"
    from "Touchpoint Customer Portal <portal@touchpointclients.com>"
    content_type "multipart/alternative"
    subject "New Touchpoint Request"
    sent_on Time.now
    body :touchpoint => touchpoint

    # Add any attachments the user has included
    touchpoint.assets.each do |asset|
      attachment :content_type => asset.file_content_type,
                 :body => File.read(asset.url)
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

这给了我以下错误No such file or directory - /system/files/7/original/image.png?1254497688,堆栈跟踪说它是调用File.read.当我访问该show.html.erb页面,并单击图像链接时http://localhost:3000/system/files/7/original/image.png?1254497688,图像显示正常.

我该如何解决这个问题?

ruby-on-rails attachment paperclip

9
推荐指数
2
解决办法
2万
查看次数

HtmlUnit下载附件

我需要保存来自网站的文件HtmlUnit.我目前正在导航到有几个使用javascript onClick()="DownloadAttachment('attachmentId')"获取文件的锚点的页面.这些文件几乎可以是任何类型的文件(xls,doc,txt,pdf,jpg等).到目前为止,虽然我一直无法找到显示如何使用保存文件的资源或示例htmlUnit.我一直在努力AttachmentHandler为此工作,因为它似乎最有可能工作,但一直没有成功.我想知道是否有其他人设法使用下载文件HtmlUnit并可以提供帮助?

java attachment htmlunit

9
推荐指数
0
解决办法
4128
查看次数

如何附加两个或多个文件并用PHP发送邮件

下面的代码只发送一个附件,但我需要附加并发送两个文件(一个rar文件和pdf)

$email_to = "$email"; // The email you are sending to (example)
$email_from = "online@example.co.in"; // The email you are sending from (example)
$email_subject = "subject line"; // The Subject of the email
$email_txt = "text body of message"; // Message that the email has in it
$fileatt = "files/example.rar"; // Path to the file (example)
$fileatt_type = "application/x-rar-compressed"; // File Type
$fileatt_name = "example.rar"; // Filename that will be used for the file as the attachment
$file = fopen($fileatt,'rb'); …
Run Code Online (Sandbox Code Playgroud)

php attachment email-attachments

9
推荐指数
4
解决办法
6万
查看次数

将PDF文件附加到电子邮件 - Swift

我想发送带有PDF附件的电子邮件.我创建了PDF文件,然后我做了以下哪些错误我相信:

// locate folder containing pdf file            
let documentsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0] as! String

let pdfFileName = documentsPath.stringByAppendingPathComponent("chart.pdf")
let fileData = NSData(contentsOfFile: pdfFileName)
mc.addAttachmentData(fileData, mimeType: "pdf", fileName: chart)
Run Code Online (Sandbox Code Playgroud)

在发送电子邮件之前,我可以看到附件chart.pdf,但是当我发送电子邮件时,它是在没有附件的情况下发送的,这是因为我没有正确附加文件.

email iphone attachment ios swift

9
推荐指数
2
解决办法
8925
查看次数

如何使用barryvdh/laravel-dompdf将PDF附加到Laravel中的电子邮件中

我知道之前已经问过这个问题,但我显然需要我的手持.我正在尝试将pdf附加到电子邮件中并将其发送出去.我已经使用PHPMailer在Laravel之外完成了它,但现在我正在尝试使用Laravel方式并且无法使其工作.我在这做错了什么?

这是我得到的错误的开始:

FileByteStream.php第144行中的Swift_IoException:无法打开文件进行读取[%PDF-1.3

    public function attach_email($id){

    $info = Load::find($id);

    $info = ['info'=>$info];

    Mail::send(['text'=>'mail'], $info, function($message){

        $pdf = PDF::loadView('pdf.invoice');

        $message->to('example@gmail.com','John Smith')->subject('Send Mail from Laravel');

        $message->from('from@gmail.com','The Sender');

        $message->attach($pdf->output());

    });
   echo 'Email was sent!';
  }
Run Code Online (Sandbox Code Playgroud)

php pdf email attachment laravel

9
推荐指数
1
解决办法
5341
查看次数