OVH Cloud OVH Cloud

envoi par email

4 réponses
Avatar
Eric
bonjour à tous

je me suis "bidouiller" un programme qui me crée un fichier texte dans un
répertoire bien précis.

cela fonctionne

je souhaiterais maintenant que le programme envoie également ce fichier en
pièce jointe par email (au travers de outlook express ou autre)

comment puis-je faire cela ?

D'avance merci de votre aide

Eric

--

4 réponses

Avatar
TouTi
Eric

je souhaiterais maintenant que le programme envoie également ce fichier en
pièce jointe par email (au travers de outlook express ou autre)



J'utilise le contrôle MAPI et un bout de code comme celui-ci

' isnetconnectonline permet de connaître l'état de connection au réseau, au
net....
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef
lpdwFlags As Long, ByVal dwReserved As Long) As Long

Public Function IsNetConnectOnline() As Boolean
Dim ret As Long
InternetGetConnectedState ret, 0&
If (ret And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED
Then rep = 1
If (ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then rep = 2
If (ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then rep
= 3
If (ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then
rep = 4
If (ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then rep
= 5
If (ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then rep = 6
Select Case rep
Case 1
msg = "Local system has a valid connection to the Internet, but it may or
may not be currently connected."
Case 2
msg = "Local system uses a local area network to connect to the Internet."
Case 3
msg = "Local system uses a modem to connect to the Internet."
Case 4
msg = "Local system is in offline mode."
Case 5
msg = "Local system uses a proxy server to connect to the Internet."
Case 6
msg = "Local system has RAS installed."
End Select
IsNetConnectOnline = rep
End Function


If IsNetConnectOnline = 4 Then
MsgBox "Enregistrez le fichier et envoyez-le moi à l'adresse
", vbInformation
Dim sFile As String
With frmMain.dlgCommonDialog
.InitDir = app.Path
.FileName = "text.txt"
.ShowSave
If Len(.FileName) = 0 Then Exit Sub
nomfic = .FileName
End With
Call sauvetxt(nomfic)
Else
rep = MsgBox("La demande va être directement envoyée à mon adresse
Email" _
+ Chr(10) + "Répondez ""ENVOYER"" à la demande d'envoi de l'email" _
+ Chr(10) + Chr(10) + "Voulez vous continuer???", _
vbYesNo + vbInformation)
If rep <> 6 Then Exit Sub
fiopte = app.Path & "text.txt"
Call sauvetxt(fiopte)
DoEvents
On Error GoTo PBenvoi
MAPISession1.SignOn
With MAPIMessages1
.SessionID = MAPISession1.SessionID
.Compose
.RecipAddress = ""
.MsgSubject = "Envoi des informations pour déblocage" 'Objet du
message
.MsgNoteText = "Demande à traiter" 'Contenu du message
.AttachmentPathName = fiopte 'fichier joint
.Send
End With
MAPISession1.SignOff
If FileExists(fiopte) Then Kill fiopte
Exit Sub

PBenvoi:
MsgBox "Votre messagerie ne peut pas envoyer les informations." +
Chr(10) + Chr(10) + _
"Il faut enregistrer le fichier puis me l'envoyer : "
With frmMain.dlgCommonDialog
.InitDir = app.Path
.FileName = "text.txt"
.ShowSave
If Len(.FileName) = 0 Then Exit Sub
nomfic = .FileName
End With
Call sauvetxt(nomfic)


TouTi
Avatar
Eric
bonjour touti

j'ai tenté de mettre ce code, sans succès ;(

le passage dans la fonction IsNetConnectOnline ne me retourne aucune valeur
rep ?

meilleures salutations

Eric

"TouTi" <gelapplication[Nospam]@tiscali.fr> a écrit dans le message de
news:43a131be$0$19690$
Eric

> je souhaiterais maintenant que le programme envoie également ce fichier


en
> pièce jointe par email (au travers de outlook express ou autre)

J'utilise le contrôle MAPI et un bout de code comme celui-ci

' isnetconnectonline permet de connaître l'état de connection au réseau,


au
net....
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef
lpdwFlags As Long, ByVal dwReserved As Long) As Long

Public Function IsNetConnectOnline() As Boolean
Dim ret As Long
InternetGetConnectedState ret, 0&
If (ret And INTERNET_CONNECTION_CONFIGURED) INTERNET_CONNECTION_CONFIGURED
Then rep = 1
If (ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then rep 2
If (ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then


rep
= 3
If (ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE


Then
rep = 4
If (ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then


rep
= 5
If (ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then rep = 6
Select Case rep
Case 1
msg = "Local system has a valid connection to the Internet, but it may or
may not be currently connected."
Case 2
msg = "Local system uses a local area network to connect to the


Internet."
Case 3
msg = "Local system uses a modem to connect to the Internet."
Case 4
msg = "Local system is in offline mode."
Case 5
msg = "Local system uses a proxy server to connect to the Internet."
Case 6
msg = "Local system has RAS installed."
End Select
IsNetConnectOnline = rep
End Function


If IsNetConnectOnline = 4 Then
MsgBox "Enregistrez le fichier et envoyez-le moi à l'adresse
", vbInformation
Dim sFile As String
With frmMain.dlgCommonDialog
.InitDir = app.Path
.FileName = "text.txt"
.ShowSave
If Len(.FileName) = 0 Then Exit Sub
nomfic = .FileName
End With
Call sauvetxt(nomfic)
Else
rep = MsgBox("La demande va être directement envoyée à mon adresse
Email" _
+ Chr(10) + "Répondez ""ENVOYER"" à la demande d'envoi de l'email" _
+ Chr(10) + Chr(10) + "Voulez vous continuer???", _
vbYesNo + vbInformation)
If rep <> 6 Then Exit Sub
fiopte = app.Path & "text.txt"
Call sauvetxt(fiopte)
DoEvents
On Error GoTo PBenvoi
MAPISession1.SignOn
With MAPIMessages1
.SessionID = MAPISession1.SessionID
.Compose
.RecipAddress = ""
.MsgSubject = "Envoi des informations pour déblocage" 'Objet du
message
.MsgNoteText = "Demande à traiter" 'Contenu du message
.AttachmentPathName = fiopte 'fichier joint
.Send
End With
MAPISession1.SignOff
If FileExists(fiopte) Then Kill fiopte
Exit Sub

PBenvoi:
MsgBox "Votre messagerie ne peut pas envoyer les informations." +
Chr(10) + Chr(10) + _
"Il faut enregistrer le fichier puis me l'envoyer : "
With frmMain.dlgCommonDialog
.InitDir = app.Path
.FileName = "text.txt"
.ShowSave
If Len(.FileName) = 0 Then Exit Sub
nomfic = .FileName
End With
Call sauvetxt(nomfic)


TouTi




Avatar
Eric
non c'est ok j'ai trouvé

un grand merci touti

Eric


"Eric" a écrit dans le message de
news:OLsf$
bonjour touti

j'ai tenté de mettre ce code, sans succès ;(

le passage dans la fonction IsNetConnectOnline ne me retourne aucune


valeur
rep ?

meilleures salutations

Eric

"TouTi" <gelapplication[Nospam]@tiscali.fr> a écrit dans le message de
news:43a131be$0$19690$
> Eric
>
> > je souhaiterais maintenant que le programme envoie également ce


fichier
en
> > pièce jointe par email (au travers de outlook express ou autre)
>
> J'utilise le contrôle MAPI et un bout de code comme celui-ci
>
> ' isnetconnectonline permet de connaître l'état de connection au réseau,
au
> net....
> Public Declare Function InternetGetConnectedState Lib "wininet.dll"


(ByRef
> lpdwFlags As Long, ByVal dwReserved As Long) As Long
>
> Public Function IsNetConnectOnline() As Boolean
> Dim ret As Long
> InternetGetConnectedState ret, 0&
> If (ret And INTERNET_CONNECTION_CONFIGURED) > INTERNET_CONNECTION_CONFIGURED
> Then rep = 1
> If (ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then rep


> 2
> If (ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then
rep
> = 3
> If (ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE
Then
> rep = 4
> If (ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then
rep
> = 5
> If (ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then rep 6
> Select Case rep
> Case 1
> msg = "Local system has a valid connection to the Internet, but it may


or
> may not be currently connected."
> Case 2
> msg = "Local system uses a local area network to connect to the
Internet."
> Case 3
> msg = "Local system uses a modem to connect to the Internet."
> Case 4
> msg = "Local system is in offline mode."
> Case 5
> msg = "Local system uses a proxy server to connect to the Internet."
> Case 6
> msg = "Local system has RAS installed."
> End Select
> IsNetConnectOnline = rep
> End Function
>
>
> If IsNetConnectOnline = 4 Then
> MsgBox "Enregistrez le fichier et envoyez-le moi à l'adresse
> ", vbInformation
> Dim sFile As String
> With frmMain.dlgCommonDialog
> .InitDir = app.Path
> .FileName = "text.txt"
> .ShowSave
> If Len(.FileName) = 0 Then Exit Sub
> nomfic = .FileName
> End With
> Call sauvetxt(nomfic)
> Else
> rep = MsgBox("La demande va être directement envoyée à mon adresse
> Email" _
> + Chr(10) + "Répondez ""ENVOYER"" à la demande d'envoi de l'email" _
> + Chr(10) + Chr(10) + "Voulez vous continuer???", _
> vbYesNo + vbInformation)
> If rep <> 6 Then Exit Sub
> fiopte = app.Path & "text.txt"
> Call sauvetxt(fiopte)
> DoEvents
> On Error GoTo PBenvoi
> MAPISession1.SignOn
> With MAPIMessages1
> .SessionID = MAPISession1.SessionID
> .Compose
> .RecipAddress = ""
> .MsgSubject = "Envoi des informations pour déblocage" 'Objet du
> message
> .MsgNoteText = "Demande à traiter" 'Contenu du message
> .AttachmentPathName = fiopte 'fichier joint
> .Send
> End With
> MAPISession1.SignOff
> If FileExists(fiopte) Then Kill fiopte
> Exit Sub
>
> PBenvoi:
> MsgBox "Votre messagerie ne peut pas envoyer les informations." +
> Chr(10) + Chr(10) + _
> "Il faut enregistrer le fichier puis me l'envoyer : "
> With frmMain.dlgCommonDialog
> .InitDir = app.Path
> .FileName = "text.txt"
> .ShowSave
> If Len(.FileName) = 0 Then Exit Sub
> nomfic = .FileName
> End With
> Call sauvetxt(nomfic)
>
>
> TouTi
>
>




Avatar
TouTi
Eric

j'ai tenté de mettre ce code, sans succès ;(
le passage dans la fonction IsNetConnectOnline ne me retourne aucune


valeur
rep ?




Voici les constantes à rajouter
Public Const INTERNET_CONNECTION_CONFIGURED = &H40
Public Const INTERNET_CONNECTION_LAN = &H2
Public Const INTERNET_CONNECTION_MODEM = &H1
Public Const INTERNET_CONNECTION_OFFLINE = &H20
Public Const INTERNET_CONNECTION_PROXY = &H4
Public Const INTERNET_RAS_INSTALLED = &H10


TouTi