Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
amcintosh  
#1 Posted : Wednesday, April 30, 2025 8:24:27 PM(UTC)
amcintosh

Rank: Newbie

Groups: Registered
Joined: 4/30/2025(UTC)
Posts: 3
Australia

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?
ivan  
#2 Posted : Friday, May 2, 2025 12:39:34 AM(UTC)
ivan

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.
amcintosh  
#3 Posted : Sunday, May 4, 2025 7:14:31 PM(UTC)
amcintosh

Rank: Newbie

Groups: Registered
Joined: 4/30/2025(UTC)
Posts: 3
Australia

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
ivan  
#4 Posted : Monday, May 5, 2025 12:48:31 AM(UTC)
ivan

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

thanks 1 user thanked ivan for this useful post.
amcintosh on 5/5/2025(UTC)
amcintosh  
#5 Posted : Monday, May 5, 2025 2:49:54 AM(UTC)
amcintosh

Rank: Newbie

Groups: Registered
Joined: 4/30/2025(UTC)
Posts: 3
Australia

Thanks: 1 times
thanks for that, s.AddAttachment works :)

Users browsing this topic
Guest
Forum Jump  
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.

Powered by YAF.NET | YAF.NET © 2003-2025, Yet Another Forum.NET
This page was generated in 0.061 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.