P
Peter Schram
I have built a vba program in Access that will send mails with word
documents. Some of the persons on the receiving-end are not able to
read the attachments. Some have an attachment with names like
ATT12345.ATT, others wordfile.doc.dat. Some can't even save or open the
files.
When using Outlook to send identical messages, they are received ok. I
set up the options of outlook to use plain-text messages and Western
European (ISO) encoding. However the encoding of the attachment seems
to differ between a manual send and automatic send.
I use the following code to send the mails, which works ok:
Dim objSession As MAPI.Session
Dim objNewMessage As MAPI.message
Dim objAttach As MAPI.Attachment
Dim objRecipient As MAPI.Recipient
' Create MAPI session
Set objSession = CreateObject("MAPI.Session")
'Logon using an existing MAPI profile with a new session
objSession.Logon showDialog:=False, ProfileInfo:="exchange-server
address" & vbLf & "account"
' Create a new message
Set objNewMessage = objSession.Outbox.Messages.Add
'edit the message to fit our needs
With objNewMessage ' message object
.Subject = varsubject
.Text = Varbody
Set objAttach = .Attachments.Add ' add the attachment
With objAttach
.Type = CdoFileData
.Position = 0 ' render at first character of message
.Name = MyfileName
.ReadFromFile varattach
End With
.Update ' update message to save attachment in MAPI system
End With
' Add recipient and resolve against the directory
Set objRecipient = objNewMessage.Recipients.Add
objRecipient.Name = varrecip
objRecipient.Resolve
' Send message
objNewMessage.Update
objNewMessage.Send
' Logoff from MAPI Session
objSession.Logoff
Is the anybody who can point me in the right direction to tackle this
problem. I need to find a way to get identical encoding on the
attachment when using the automatic way.
Thanks in advance,
Petetr Schram
documents. Some of the persons on the receiving-end are not able to
read the attachments. Some have an attachment with names like
ATT12345.ATT, others wordfile.doc.dat. Some can't even save or open the
files.
When using Outlook to send identical messages, they are received ok. I
set up the options of outlook to use plain-text messages and Western
European (ISO) encoding. However the encoding of the attachment seems
to differ between a manual send and automatic send.
I use the following code to send the mails, which works ok:
Dim objSession As MAPI.Session
Dim objNewMessage As MAPI.message
Dim objAttach As MAPI.Attachment
Dim objRecipient As MAPI.Recipient
' Create MAPI session
Set objSession = CreateObject("MAPI.Session")
'Logon using an existing MAPI profile with a new session
objSession.Logon showDialog:=False, ProfileInfo:="exchange-server
address" & vbLf & "account"
' Create a new message
Set objNewMessage = objSession.Outbox.Messages.Add
'edit the message to fit our needs
With objNewMessage ' message object
.Subject = varsubject
.Text = Varbody
Set objAttach = .Attachments.Add ' add the attachment
With objAttach
.Type = CdoFileData
.Position = 0 ' render at first character of message
.Name = MyfileName
.ReadFromFile varattach
End With
.Update ' update message to save attachment in MAPI system
End With
' Add recipient and resolve against the directory
Set objRecipient = objNewMessage.Recipients.Add
objRecipient.Name = varrecip
objRecipient.Resolve
' Send message
objNewMessage.Update
objNewMessage.Send
' Logoff from MAPI Session
objSession.Logoff
Is the anybody who can point me in the right direction to tackle this
problem. I need to find a way to get identical encoding on the
attachment when using the automatic way.
Thanks in advance,
Petetr Schram