From 6a76df5cbc2a559c61d8ed7bc9bcddfad8564a44 Mon Sep 17 00:00:00 2001
From: Madhu S R <madhu.sr@vtigersolutions.com>
Date: Fri, 12 Apr 2024 13:40:55 +0530
Subject: [PATCH] #Fixes::madhusr::PDF attachment is not sending when we click
 on the 'send email as attachment'

---
 .gitignore                            | 1 +
 modules/Emails/views/MassSaveAjax.php | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 1b58a9326..585abce2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 vendor/*
 !vendor/.htaccess
+.vscode/*
\ No newline at end of file
diff --git a/modules/Emails/views/MassSaveAjax.php b/modules/Emails/views/MassSaveAjax.php
index db74b8a1f..f2ec042ee 100644
--- a/modules/Emails/views/MassSaveAjax.php
+++ b/modules/Emails/views/MassSaveAjax.php
@@ -196,8 +196,12 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View {
 					 * Ex: for PDF: if filename - abc_md5(abc).pdf then raw filename - abc.pdf
 					 * For Normal documents: rawFileName is not exist in the attachments info. So it fallback to normal filename
 					 */
-					$rawFileName = $existingAttachInfo['attachment'];
+					$rawFileName = $existingAttachInfo['storedname'];
 					$file_name = $existingAttachInfo['storedname'];
+					if(!$rawFileName) {
+						$rawFileName = $existingAttachInfo['attachment'];
+						$file_name = $existingAttachInfo['attachment'];
+					}
 					$path = $existingAttachInfo['path'];
 					$fileId = $existingAttachInfo['fileid'];
 
-- 
GitLab