File wont Save

D

DS

I'm using the following code to save E-Mails from within Access but it
wont save the Email or the Attachment. Area marked HERE is where I
think the problem is.
Any help appreciated.
Thanks
DS

Private Sub Form_Load()
Dim m As OSPOP3.Message
Dim h As OSPOP3.Header
Dim s As String
Dim s1 As String
Dim e As OSPOP3.Email
Dim a As OSPOP3.Attachment
Dim iCount As Integer
Dim i As Integer
Dim j As Integer

'On Error GoTo err_handler
i = Form_frmEmail.lvwMessages

If Form_frmEmail.bHeadersOnly Then
Set m = Form_frmEmail.oSession.GetMessageHeaders(i)
Else
Set m = Form_frmEmail.oSession.GetMessage(i)
End If
Caption = "Message " & i

txtFromName = m.Sender.Name
txtFromEmail = m.Sender.Address

s1 = ""
For Each e In m.Recipients
s1 = s1 & e.Address & ";" & e.Name & ";"
Next
lstTo.RowSource = s1

txtSubject = m.Subject
txtDate = m.DateSent
txtContentType = m.ContentType
txtCharset = m.Charset
txtUIDL = m.UIDL

For Each h In m.Headers
txtHeaders = txtHeaders & h.Name & ": "
For Each s In h.Values
txtHeaders = txtHeaders & s & "; "
Next
txtHeaders = txtHeaders & vbCrLf
Next

If Not Form_frmEmail.bHeadersOnly Then
txtBody = m.Body
txtHTML = m.HTMLBody

s1 = ""
For Each a In m.Attachments
j = j + 1
s1 = s1 & a.AttachmentName & ";" & a.ContentDisposition & ";" &
a.ContentTransferEncoding & ";" & a.ContentType & ";"
a.Save "C:\David" & a.Filename HERE
Next
lstAttachments.RowSource = s1

m.Save "C:\David" & m.UIDL & ".eml" HERE
End If

err_handler:
If Err.Number <> 0 Then MsgBox "Error " & Err.Number & ": " &
Err.Description
End Sub

Private Sub UserForm_Resize()
With tvw
.Left = 0
.Top = 0
.Height = Height - 420
.Width = Width - 120
End With
End Sub
 
S

Someone

Looking at what you have put here:

a.Save "C:\David" & a.Filename HERE
Next
lstAttachments.RowSource = s1

m.Save "C:\David" & m.UIDL & ".eml" HERE
End If

What strikes me is that you haven't put a "\" between C:\David and the
filename. Assume the filename is file.eml, then you're attempting to save
as C:\Davidfile.eml which won't work.

Try doing a.Save "C:\David\" & a.Filename
and
m.Save "C:\David\" & m.UIDL & ".eml"

I might be wrong but this seems a good place to start.

M
 
D

DS

Someone said:
Looking at what you have put here:

a.Save "C:\David" & a.Filename HERE
Next
lstAttachments.RowSource = s1

m.Save "C:\David" & m.UIDL & ".eml" HERE
End If

What strikes me is that you haven't put a "\" between C:\David and the
filename. Assume the filename is file.eml, then you're attempting to save
as C:\Davidfile.eml which won't work.

Try doing a.Save "C:\David\" & a.Filename
and
m.Save "C:\David\" & m.UIDL & ".eml"

I might be wrong but this seems a good place to start.

M
Your right that worked!
Thank You
DS
 
D

DS

Graham said:
Hi David (?)

You seem to be using a third-party COM add-in, the OstroSoft POP3 library -
is that correct?

I suggest you try their own support forum at
http://www.ostrosoft.com/forum/forum_topics.asp?FID=46
Its correct, so what does that mean...COM. does that mean all of my
E-Mails go through their site, I'm kinda flying blind here on this one.
The following post actually gave me the info I needed about the saving
of the file, but if you know anything about this COM thing I'd
appreciate any input.
Thank You
DS
 
D

DS

Stefan said:
hi,


Normal users don't have NTFS write permissions on C:.


mfG
--> stefan <--
Thanks, I did this and it worked...
a.Save "C:\David\" & a.Filename
DS
 
G

Graham Mandeno

Hi DS

No - the "COM" in "COM Add-in" stands for "Component Object Model" and has
nothing to do with the dot-com in a URL.

Your code will be retrieving email directly from your own ISP's mail server,
and nothing will be going via OstraSoft's site.
 

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