We have a cript that mails us attachments in PDF format.
Worked for years and suddenly stopped working.
PDF's now are created and mailed, but not mailed as PDF, but as textfiles instead, with .txt extension.
$mail_handler = new PHPMailer(); // defaults to using php "mail()"
//$mail_handler->Body = $contents_mail_handler;
$mail_handler->Body = $contents_mail_handler;
$mail_handler->From = MAIL_SENDER;
$mail_handler->FromName = MAIL_SENDER;
$mail_handler->Subject = "#$inserted_order_id: $name - € $total";
$mail_handler->AddAddress($email_handler, $email_handler);
$file_nl = "_orders/" . $filename_nl;
$mail_handler->AddAttachment($file_nl,$filename_nl); // attachment
$file_en = "_orders/" . $filename_en;
$mail_handler->AddAttachment($file_en,$filename_en); // attachment
$file_fr = "_orders/" . $filename_fr;
$mail_handler->AddAttachment($file_fr,$filename_fr); // attachment
$mail_handler->Send();
$mail_handler->ClearAddresses();
$mail_handler->ClearAttachments();
text attachment content example : http://pastebin.com/tdfKfQCq
Any help is highly appreciated, thanks!
Bas
Thanks. Path was ok. Updated phpmailer, fixed the problem.
Related
I am trying to add an Image to an Email Body.
I am using Outlook 16 and Python 3.7 to do this.
The mail gets sent from Mailbox.
Here is my code function to send email and how can I add an Image at the end of the email.
def send_email(sender,recipient):
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = Subject_Req
mail.HTMLBody = Content_Email
mail.SentOnBehalfOfName = sender
mail.GetInspector
mail.Send()
The Image is present in my local network :- C:\Users\Sid\AppData\Roaming\Microsoft\Signatures\My Project\image001.png
The Image is nothing but the logo which I want to put at the last part of the HTML body.
So basically from the function it will be Content_Email + This image.
I tried some code, what it does is :- it sends an "X" mark at the end in place of the image itself to the recipient.
And when I send it to myself, It puts the "X" mark but I get an option to download pictures on right click and it gets the Image.
What I would like to do is, put the Image instead of the "X" for both the cases without the user having to have access to that Image.
How can I do this using Python. The solution in here seems to be working with VBA : https://www.experts-exchange.com/questions/26481413/Problem-inserting-HTML-images-into-the-body-of-a-messge.html
I managed to get this to work through attachment.PropertyAccessor.SetProperty function.
def send_email(sender,recipient):
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = Subject_Req
attachment = mail.Attachments.Add(signatureimage)
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "MyId1")
mail.HTMLBody = Content_Email + "<html><body><img src=""cid:MyId1""></body></html>"
mail.SentOnBehalfOfName = sender
mail.GetInspector
mail.Send()
#Change the Paths here, if ran from a different location
signatureimage = "C:\\Users\\Sid\\AppData\\Roaming\\Microsoft\\Signatures\\My Project\\image001.png"
This would mean, it will embed the Image and not link the Picture to a link. Linking to a picture expects the recipients to have access to that particular picture location.
Also, for a learning this link doesn't change at all :- http://schemas.microsoft.com/mapi/proptag/0x3712001F
I am tring to send some new Excle files that i created before.
When i try to send them with Lotus Notes i get an OLE error but when i try to send a test file it works without Problem. Can someone give me a tip where the Problem lies?
This i my Attachment part in the E-Mail function:
stAttachment = EmailAttachment
Set AttachMe = MailDoc.CREATERICHTEXTITEM("stAttachment")
Set EmbedObj = AttachMe.EMBEDOBJECT(1454, "", stAttachment, "stAttachment")
Here i put the targent file:
Filename = "C:\Users\User\Desktop\Excel Notes\test.xlsm"
Filename = "C:\Users\user\Desktop\Excel Notes\generated.xlsm"
EMail.EMailBuild EmailAdress, EmailHeader, EmailText, Filename
when i try the test file it functions but when i set the generatet file i get this error
waiting for another application to complete an OEL action
I am currently using Outlook 2010 and I am currently able to manually search a folder in outlook by using the "More" button and adding attachments:yes and attachment contains: where I input the filename to find an email and get the timestamp from when it was sent. I have thousands of attachments for which I need to do this and I would like to automate the process but I am an outlook vba noobie and I do not know the command to perform the search by attachment name, I have tried googling this but to no avail any help would be greatly appreciated thanks!
You can use Restrict https://msdn.microsoft.com/en-us/library/office/ff869597.aspx
Example here: http://www.jpsoftwaretech.com/save-all-attachments-from-selected-folder/
Set newItems = itms.Restrict("[Attachment] > 0")
Combined with:
attName = MsgAttach.Item(attachmentNumber)
If InStr(attName, "search string here") Then
Debug.Print "- " & attName
End If
Outlook Object Model will not let you search for an item with a particular attachment file name. You can explicitly loop through all items in the folder and check the attachment filename, but that will be highly inefficient.
On the Extended MAPI level (C++ or Delphi) you can create a subrestriction on the attachments. If using Redemption is an option (I am its author), it allows to specify Attachments in RDOItems.Find/Restrict:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set vFolder = Session.GetFolderFromID(Application.ActiveExplorer.CurrentFolder.EntryID)
set vItems = vFolder.Items
set vMsg = vItems.Find("Attachments LIKE '%.zip%' ")
while not (vMsg Is Nothing)
MsgBox vMsg.Subject
set vMsg = vItems.FindNext
wend
Hey I am trying to create a excel file in cakephp . I have a working download link like url/fetchreport/2015-02-1 I am able to download excel from this url . Is there any way by which I can use this URL and send downloaded excel in email as a attached file .
You can use this code for attaching a file in your email in cakephp.
$this->Email->filePaths = array('/path/to/your/file/');
$this->Email->attachments= array('file.xls');
$this->Email->to = 'example#example.com';
$this->Email->subject = 'xyz';
$this->Email->replyTo = 'client#mail';
$this->Email->from = 'anything#mail';
$this->Email->sendAs = 'html';
I want to use matlab to automatically send the email (through outlook) to others while I want the table is to be shown in the body of email, not as the attachment.
Suppose i have a spreadsheet named ABC.xlsx, if I want to extract one sheet and put it in the body of email, what should I do?
I use the following code,
h = actxserver('outlook.Application');
mail = h.CreateItem('olMail');
mail.Subject = 'test';
mail.To = ['***#****.com'];
mail.BodyFormat = 'olFormatHTML';
mail.HTMLBody = 'This is a test for email sending!';
mail.attachments.Add('ABC.xlsx');
mail.Send;
h.release;
I recommend you take a look at function xlsread, documented here. After reading the desired contents of the xlsx page, you can format them as an html table and put it in mail.HTMLBody.