close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Universal Email file attachment problem

Thread began 9/04/2009 6:35 am by steen120697 | Last modified 9/08/2009 6:16 pm by Ray Borduin | 1818 views | 7 replies |

steen120697

Universal Email file attachment problem

I use UE to send attachments to different users. I retrieve email and attachment (file2send) information from a database.

If the recordset contains just 1 record, everything works fine. More than 1 record and hell breaks lose (= hundreds of emails sent).

The file2send contains the physical path.

I'd appreciate som assistance, please...


<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_dbburner_STRING
Recordset1.Source = "SELECT * FROM LOGBOG where keycode = '" & keycode & "' and email = '" & email & "'"
response.write(Recordset1.Source)
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<!--#include file="../WA_Universal_Email/AspMail_VB.asp" -->
<!--#include file="../WA_Universal_Email/MailFormatting_VB.asp" -->
<%
function WA_Universal_Email_1_SendMail(RecipientEmail)
dim MailObject, MailAttachments, MailBCC, MailCC, MailTo, MailBodyFormat, MailBody, MailImportance, MailFrom, MailSubject
MailAttachments = ""
MailBCC = ""
MailCC = ""
MailTo = ""
MailBodyFormat = ""
MailBody = ""
MailImportance = ""
MailFrom = "John Doe|WA|john@company.com"
MailSubject = "Photos"

'Global Variables
gBodyFormat = ""

set WA_MailObject = WAUE_Definition("smtp.domain.com")

if (RecipientEmail <> "") then
set WA_MailObject = WAUE_AddRecipient(WA_MailObject,RecipientEmail)
else
'To Entries
end if

'Attachment Entries
while (NOT Recordset1.EOF)
set WA_MailObject = WAUE_AddAttachment(WA_MailObject,"" & cStr(Recordset1.Fields.Item("file2send").Value) & "")
Recordset1.MoveNext()
wend
if (Recordset1.CursorType > 0) then
Recordset1.MoveFirst
else
Recordset1.Requery
end if

'BCC Entries

'CC Entries

'Character Set

'Body Format
set WA_MailObject = WAUE_BodyFormat(WA_MailObject,0)
MailBodyFormat = gBodyFormat

'Set Importance
set WA_MailObject = WAUE_SetImportance(WA_MailObject,"3")

'Start Mail Body
MailBody = MailBody & "Cool"
'End Mail Body

set WA_MailObject = WAUE_SendMail(WA_MailObject,MailAttachments,MailBCC,MailCC,MailTo,MailImportance,MailFrom,MailSubject,MailBody)

set WA_MailObject = nothing
end function
%>
<%
if ((NOT (Recordset1.EOF AND Recordset1.BOF))) then
'WA Universal Email object="AspMail"
'Send Loop Once Per Entry
while (NOT Recordset1.EOF)
WA_Universal_Email_1_SendMail("" & cStr(Recordset1.Fields.Item("email").Value) & "")
Recordset1.MoveNext()
wend
if (Recordset1.CursorType > 0) then
Recordset1.MoveFirst
else
Recordset1.Requery
end if

'Send Mail All Entries
if (""<>"") then
Response.Redirect("")
end if
end if
%>

Sign in to reply to this post

Ray BorduinWebAssist

You need to use the full (drive relative) path to the file being uploaded.

I'm not sure exactly what you have stored in your database, but probably the answer is to use realpath() like:


set WA_MailObject = WAUE_AddAttachment(WA_MailObject,"" & cStr(realpath(Recordset1.Fields.Item("file2send").Value)) & "")

Sign in to reply to this post

steen120697

I am already using the full path: d:\www2\burner-international\img\banner\1.jpg

I copied your suggestion:

set WA_MailObject = WAUE_AddAttachment(WA_MailObject,"" & cStr(realpath(Recordset1.Fields.Item("file2send"). Value)) & "")

That gives me this message:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'realpath'

The odd thing is I only have a problem when my recordset has more than one record. Everything's working fine with only one record/one attachment.

Sign in to reply to this post

Ray BorduinWebAssist

Sorry I answered too quickly... realpath is a php function... please ignore my previous response.

In ASP it is Server.MapPath(), but if you already have the full path in the database, that shouldn't be the issue.

Are you using the same recordset for the loops as the attachments? Is it possible the path is wrong in one of them?

Sign in to reply to this post

steen120697

This is the code. I'm now using server.mappath. I have 3 files; they work individually but I cannot send 2 or more files at the same time...

<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_dbburner_STRING
Recordset1.Source = "SELECT * FROM LOGBOG where keycode = '" & keycode & "' and email = '" & email & "'"
response.write(Recordset1.Source)
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<!--#include file="../WA_Universal_Email/AspMail_VB.asp" -->
<!--#include file="../WA_Universal_Email/MailFormatting_VB.asp" -->
<%
function WA_Universal_Email_1_SendMail(RecipientEmail)
dim MailObject, MailAttachments, MailBCC, MailCC, MailTo, MailBodyFormat, MailBody, MailImportance, MailFrom, MailSubject
MailAttachments = ""
MailBCC = ""
MailCC = ""
MailTo = ""
MailBodyFormat = ""
MailBody = ""
MailImportance = ""
MailFrom = "John Doe|WA|john@domain.com"
MailSubject = "Photos"

'Global Variables
gBodyFormat = ""

set WA_MailObject = WAUE_Definition("smtp.domain.dk")

if (RecipientEmail <> "") then
set WA_MailObject = WAUE_AddRecipient(WA_MailObject,RecipientEmail)
else
'To Entries
end if

'Attachment Entries
while (NOT Recordset1.EOF)
set WA_MailObject = WAUE_AddAttachment(WA_MailObject,"" & cStr(Server.MapPath((Recordset1.Fields.Item("file2send")). Value)) & "")
Recordset1.MoveNext()
wend
if (Recordset1.CursorType > 0) then
Recordset1.MoveFirst
else
Recordset1.Requery
end if

'BCC Entries

'CC Entries

'Character Set

'Body Format
set WA_MailObject = WAUE_BodyFormat(WA_MailObject,0)
MailBodyFormat = gBodyFormat

'Set Importance
set WA_MailObject = WAUE_SetImportance(WA_MailObject,"3")

'Start Mail Body
MailBody = MailBody & "Cool"
'End Mail Body

set WA_MailObject = WAUE_SendMail(WA_MailObject,MailAttachments,MailBCC,MailCC,MailTo,MailImportance,MailFrom,MailSubject,MailBody)

set WA_MailObject = nothing
end function
%>

Sign in to reply to this post

Ray BorduinWebAssist

Are you using the same recordset somewhere else? When you try to send multiple it starts sending none?

I'll create a support incident so that somebody can look into this further with you.

Sign in to reply to this post

steen120697

I am not using the same recordset anywhere else. Please note that when I want to send multiple emails I send hundreds of emails even if my recordset only contains 2 records.

Sign in to reply to this post

Ray BorduinWebAssist

I have created an incident so that someone can investigate this further with you.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...