Rank: Newbie
Groups: Registered
Joined: 4/30/2025(UTC)
Posts: 3
Thanks: 1 times
Hi all
I'm trying to send an email containing the current workbook as an attachment, however the email being sent out without the file being attached, with no Error message shown either.
In the main sub - I call the function using the parameters below
Code: eMailTo eto:=eto, ecc:=ecc, subj:=esub, body:=RangetoHTML(rng), attach:=ActiveWorkbook.FullName
and the function used here is -
Code: Function eMailTo(eto, ecc, subj, body, attach)
Dim e
Set e = CreateObject("EaSEndMailObj.mail")
'Set e = New EASendMailObjLib.Mail
With e
.LicenseCode = (Removed)
.ServerAddr = (Removed)
.UserName = (Removed)
.Password = (Removed)
.ServerPort = 25
.ConnectType = 4
.FromAddr = (Removed)
.AddRecipientEx eto, 0
.AddRecipientEx ecc, 1
.BodyFormat = 1
.BodyText = body
.Subject = subj
End With
If e.Addattachments(attach) <> 0 Then
MsgBox "Email Attachment Error: " & e.GetLastErrDescription()
End If
Application.DisplayStatusBar = True
Application.StatusBar = "Connecting " & e.ServerAddr & " ..."
e.Asynchronous = 1
' InitVariables
' CurrentEmailIsFinished = False
e.SendMail
End Function
anybody know where i may have screwed up?
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,156
Thanks: 9 times Was thanked: 56 time(s) in 56 post(s)
Hi, because opened workbook doesn't share read or write, so you cannot attach current workbook. You can save a copy of the workbook to the disk, then try to attached the copy.
Rank: Newbie
Groups: Registered
Joined: 4/30/2025(UTC)
Posts: 3
Thanks: 1 times
Thanks for your response, I've added tfile = "Pallet Movements for " & Format(Now, "dd-mm-yy") & ".xlsx" ActiveWorkbook.SaveCopyAs tfile If e.AddAttachments(tfile) <> 0 Then MsgBox "Email Attachment Error: " & e.GetLastErrDescription() End If still no go unfortunately
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,156
Thanks: 9 times Was thanked: 56 time(s) in 56 post(s)
Please use e.AddAttachment instead of AddAttachments.
AddAttachments adds all files in a folder, so the parameter should be a folder path, not a file.
If you want to add a file attachment, please use AddAttachment.
and please also use full file path instead of only file name.
Edited by user Monday, May 5, 2025 12:49:09 AM(UTC)
| Reason: Not specified
1 user thanked ivan for this useful post.
Rank: Newbie
Groups: Registered
Joined: 4/30/2025(UTC)
Posts: 3
Thanks: 1 times
thanks for that, s.AddAttachment works :)
Forum Jump
EmailArchitect Support
Email Component Development
- EASendMail SMTP Component - .NET Version
- EASendMail SMTP Component - Windows Store Apps
- EASendMail SMTP ActiveX Object
- EAGetMail POP3 & IMAP4 Component - .NET Version
- EAGetMail POP3 & IMAP4 ActiveX Object
Exchange Server and IIS SMTP Plugin
- DomanKeys/DKIM for Exchange Server and IIS SMTP
- Disclaimer and S/MIME for Exchange Server and IIS
EmailArchitect Email Server
- EmailArchitect Email Server (General)
- EmailArchitect Email Server Development
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.