[Winsock] Send Big Attach

A

ALESSANDRO Baraldi

Hi all NG.

Using Winsock.ocx control my Mail Attach limit is less then 1Mb.

How can i send more than this...!

Now i verify the buffer but the error come from provider.

Any suggestion w'll be appreciated.
 
A

Alex Dybenko

Hi Alessandro,
so maybe provider does not allow you to send such a big emails? what error
you get?
 
A

ALESSANDRO Baraldi

Alex Dybenko said:
Hi Alessandro,
so maybe provider does not allow you to send such a big emails? what error
you get?

Hi mr. Alex

Around 800÷1000 Kb i have the max upper limit.
It's not the provider because with Outlook_Express i usually
send more than 5Mb in a single File Attach....!

This is a part of Code wich i use to send Attach the error come from
HandleError
and no Error Number and no Description....!
It can be caused from TimeOut Socket...?
(but with Winsock.Ocx i don't know how to modify this time....!)

I'm not sure it's TimeOut but now with DelayLooping on Buffer my error come
just 1,7Mb....!!!!!!

If i send many attachs and the total dimension was less then 1Mb no problem
at all
so i'm sure that the code is correct...!

If Len(mAttach) > 0 Then
Dim lPtr As Long
Dim Attachment As Variant
Dim EncodeAttach As String

msgBody = msgBody & "--" & strBoundary & "--" & vbCrLf & vbCrLf

Attachment = Split(mAttach, ";")

' Check and send each single attach
For lPtr = 0 To UBound(Attachment) - 1
' test if the attach exist
If Dir(Attachment(lPtr)) = "" Then
'AddError ERR_FILE_NOT_EXIST
'
'Not implemented the Error JUST SKIPP
Goto Skipp
End If
'This codify on 64Base my AttachPointer
EncodeAttach = Code64(CStr(Attachment(lPtr)))
AttachName = ParseFileName(CStr(Attachment(lPtr)))
msgBody = msgBody & "--" & strBoundary & vbCrLf
msgBody = msgBody & "Content-Type: application/octet-stream;"
& vbCrLf
msgBody = msgBody & vbTab & "name=" & Chr$(34) & AttachName &
Chr$(34) & vbCrLf
msgBody = msgBody & "Content-Transfer-Encoding: base64" &
vbCrLf
msgBody = msgBody & "Content-Disposition: attachment;" &
vbCrLf
msgBody = msgBody & vbTab & "filename=" & Chr$(34) &
AttachName & Chr$(34) & vbCrLf & vbCrLf
msgBody = msgBody & EncodeAttach & vbCrLf
wsk.SendData (msgBody)
msgBody = ""

' Waiting for Buffer dimension
Do While mBytesRemaining > 4096
' Gestione del TIMEOUT
fStart = Timer
If fStart < 86400 Then
fTimeOut = fStart
Else
fTimeOut = (fStart - 86400)
End If
' If mBytesRemaining change i still sending....!
' [mBytesRemaining] come from Sending Progress Winsock
lSendBuffSize = mBytesRemaining
Do Until lSendBuffSize <> mBytesRemaining
If mBytesRemaining < 4096 Then Exit Do
If Timer >= fTimeOut Then
GoTo HandleError
End If
Sleep (10)
DoEvents
Loop
Loop
Skipp:

Next
End If
' CLOSE MAIL MESSAGE
msgBody = ""
msgBody = msgBody & vbCrLf
msgBody = msgBody & "--" & strBoundary & "--" & vbCrLf
msgBody = msgBody & vbCrLf & "." & vbCrLf

DoEvents
wsk.SendData (msgBody)
Call getreply: If Left(strData, 3) <> "250" Then GoTo HandleError

GoTo CHIUDI

HandleError:
MsgBox "Server error Replay: " & vbCrLf & wsk.RemoteHost & vbCrLf & _
Err.Description & " - " & Err.Number

wsk.Close: SendMail = -1

CHIUDI:
End Function

Many thanks for your help.
 
A

Alex Dybenko

Hi,
i think you have to modify your code - you have to send data using smaller
pieces
Look at following tread:
http://groups-beta.google.com/group..._frm/thread/92d91c573d601a15/bad427fcff1004c8

HTH
Alex

ALESSANDRO Baraldi said:
Alex Dybenko said:
Hi Alessandro,
so maybe provider does not allow you to send such a big emails? what
error
you get?

Hi mr. Alex

Around 800÷1000 Kb i have the max upper limit.
It's not the provider because with Outlook_Express i usually
send more than 5Mb in a single File Attach....!

This is a part of Code wich i use to send Attach the error come from
HandleError
and no Error Number and no Description....!
It can be caused from TimeOut Socket...?
(but with Winsock.Ocx i don't know how to modify this time....!)

I'm not sure it's TimeOut but now with DelayLooping on Buffer my error
come
just 1,7Mb....!!!!!!

If i send many attachs and the total dimension was less then 1Mb no
problem
at all
so i'm sure that the code is correct...!

If Len(mAttach) > 0 Then
Dim lPtr As Long
Dim Attachment As Variant
Dim EncodeAttach As String

msgBody = msgBody & "--" & strBoundary & "--" & vbCrLf & vbCrLf

Attachment = Split(mAttach, ";")

' Check and send each single attach
For lPtr = 0 To UBound(Attachment) - 1
' test if the attach exist
If Dir(Attachment(lPtr)) = "" Then
'AddError ERR_FILE_NOT_EXIST
'
'Not implemented the Error JUST SKIPP
Goto Skipp
End If
'This codify on 64Base my AttachPointer
EncodeAttach = Code64(CStr(Attachment(lPtr)))
AttachName = ParseFileName(CStr(Attachment(lPtr)))
msgBody = msgBody & "--" & strBoundary & vbCrLf
msgBody = msgBody & "Content-Type:
application/octet-stream;"
& vbCrLf
msgBody = msgBody & vbTab & "name=" & Chr$(34) & AttachName
&
Chr$(34) & vbCrLf
msgBody = msgBody & "Content-Transfer-Encoding: base64" &
vbCrLf
msgBody = msgBody & "Content-Disposition: attachment;" &
vbCrLf
msgBody = msgBody & vbTab & "filename=" & Chr$(34) &
AttachName & Chr$(34) & vbCrLf & vbCrLf
msgBody = msgBody & EncodeAttach & vbCrLf
wsk.SendData (msgBody)
msgBody = ""

' Waiting for Buffer dimension
Do While mBytesRemaining > 4096
' Gestione del TIMEOUT
fStart = Timer
If fStart < 86400 Then
fTimeOut = fStart
Else
fTimeOut = (fStart - 86400)
End If
' If mBytesRemaining change i still sending....!
' [mBytesRemaining] come from Sending Progress
Winsock
lSendBuffSize = mBytesRemaining
Do Until lSendBuffSize <> mBytesRemaining
If mBytesRemaining < 4096 Then Exit Do
If Timer >= fTimeOut Then
GoTo HandleError
End If
Sleep (10)
DoEvents
Loop
Loop
Skipp:

Next
End If
' CLOSE MAIL MESSAGE
msgBody = ""
msgBody = msgBody & vbCrLf
msgBody = msgBody & "--" & strBoundary & "--" & vbCrLf
msgBody = msgBody & vbCrLf & "." & vbCrLf

DoEvents
wsk.SendData (msgBody)
Call getreply: If Left(strData, 3) <> "250" Then GoTo HandleError

GoTo CHIUDI

HandleError:
MsgBox "Server error Replay: " & vbCrLf & wsk.RemoteHost & vbCrLf & _
Err.Description & " - " & Err.Number

wsk.Close: SendMail = -1

CHIUDI:
End Function

Many thanks for your help.
 
A

ALESSANDRO Baraldi

Alex Dybenko said:
Hi,
i think you have to modify your code - you have to send data using smaller
pieces
Look at following tread:
http://groups-beta.google.com/group..._frm/thread/92d91c573d601a15/bad427fcff1004c8

HTH
Alex


I can Split(msgBody,vbnewline) and cicle trought this Array
sending each loop a part of Attach...!
The codeBase64 have a newLine each 76Chars so.... may be good..?

So this is my Single Attach
AttachName = ParseFileName(CStr(Attachment(lPtr)))
msgBody = msgBody & "--" & strBoundary & vbCrLf
msgBody = msgBody & "Content-Type: application/octet-stream;" &
vbCrLf
msgBody = msgBody & vbTab & "name=" & Chr$(34) & AttachName &
Chr$(34) & vbCrLf
msgBody = msgBody & "Content-Transfer-Encoding: base64" & vbCrLf
msgBody = msgBody & "Content-Disposition: attachment;" & vbCrLf
msgBody = msgBody & vbTab & "filename=" & Chr$(34) & AttachName &
Chr$(34) & vbCrLf & vbCrLf
wsk.SendData (msgBody)

EncodeAttach = Code64(CStr(Attachment(lPtr)))

'Now i SPLIT in a very Small pieces...!

varAttach=Split(EncodeAttach ,vbNewLine)
For x=0 to Ubound(varAttach())
wsk.SendData varattach(x) & vbCrLf
DoEvents
next
...................................

My only thing is that is already asincronus....!
Probably i'll need to send data only after Wsk_DataArrival check

If strResponseCode = "250" then send again...!

What do you think about...?

Thanks.

Last but not for last i give you and all your Family my best wishes for
Christmas Day
 
A

Alex Dybenko

Ciao Alessanro,
yes, i think you have to implement Wsk_DataArrival event, so you send a
piece, wait for ok, then send next one, etc

Alex
 
A

ALESSANDRO Baraldi

Alex Dybenko said:
Ciao Alessanro,
yes, i think you have to implement Wsk_DataArrival event, so you send a
piece, wait for ok, then send next one, etc

Alex

Yesssss...!
Work good on the test i'm sending more than 2 Mb with no error.

A single very importantb attention is:

the queue

At the end of Attachmente loop the buffer is already full and
i need to wait just one more 354 Replay before sending DOT
for termination....!

Without this the mail will send, but the error JUST come.

Now ALL OK.

Lot of Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top